Merge branch 'feat/1.0.7/short-id' into test
This commit is contained in:
@@ -113,6 +113,7 @@ func (ac *AnswerController) Add(ctx *gin.Context) {
|
||||
if handler.BindAndCheck(ctx, req) {
|
||||
return
|
||||
}
|
||||
req.QuestionID = uid.DeShortID(req.QuestionID)
|
||||
req.UserID = middleware.GetLoginUserIDFromContext(ctx)
|
||||
|
||||
can, err := ac.rankService.CheckOperationPermission(ctx, req.UserID, permission.AnswerAdd, "")
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"github.com/answerdev/answer/internal/service/role"
|
||||
usercommon "github.com/answerdev/answer/internal/service/user_common"
|
||||
"github.com/answerdev/answer/pkg/encryption"
|
||||
"github.com/answerdev/answer/pkg/uid"
|
||||
"github.com/segmentfault/pacman/errors"
|
||||
"github.com/segmentfault/pacman/log"
|
||||
)
|
||||
@@ -167,7 +168,7 @@ func (as *AnswerService) Insert(ctx context.Context, req *schema.AnswerAddReq) (
|
||||
if err != nil {
|
||||
log.Error("IncreaseAnswerCount error", err.Error())
|
||||
}
|
||||
err = as.questionCommon.UpdateLastAnswer(ctx, req.QuestionID, insertData.ID)
|
||||
err = as.questionCommon.UpdateLastAnswer(ctx, req.QuestionID, uid.DeShortID(insertData.ID))
|
||||
if err != nil {
|
||||
log.Error("UpdateLastAnswer error", err.Error())
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ func (ns *NotificationCommon) SendNotificationToAllFollower(ctx context.Context,
|
||||
}
|
||||
condObjectID := msg.ObjectID
|
||||
if len(questionID) > 0 {
|
||||
condObjectID = questionID
|
||||
condObjectID = uid.DeShortID(questionID)
|
||||
}
|
||||
userIDs, err := ns.followRepo.GetFollowUserIDs(ctx, condObjectID)
|
||||
if err != nil {
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
"github.com/answerdev/answer/internal/service/role"
|
||||
usercommon "github.com/answerdev/answer/internal/service/user_common"
|
||||
"github.com/answerdev/answer/pkg/htmltext"
|
||||
"github.com/answerdev/answer/pkg/uid"
|
||||
"github.com/segmentfault/pacman/errors"
|
||||
"github.com/segmentfault/pacman/log"
|
||||
"xorm.io/xorm"
|
||||
@@ -124,6 +125,7 @@ func (rs *RankService) CheckOperationPermissions(ctx context.Context, userID str
|
||||
|
||||
// CheckOperationObjectOwner check operation object owner
|
||||
func (rs *RankService) CheckOperationObjectOwner(ctx context.Context, userID, objectID string) bool {
|
||||
objectID = uid.DeShortID(objectID)
|
||||
objectInfo, err := rs.objectInfoService.GetInfo(ctx, objectID)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
|
||||
Reference in New Issue
Block a user