Skip to content

Commit 7952075

Browse files
committed
fix: normalize ObjectID and CommentID in comment requests
1 parent 52d057e commit 7952075

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

internal/controller/comment_controller.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333
"github.com/apache/answer/internal/service/comment"
3434
"github.com/apache/answer/internal/service/permission"
3535
"github.com/apache/answer/internal/service/rank"
36+
"github.com/apache/answer/pkg/uid"
3637
"github.com/gin-gonic/gin"
3738
"github.com/segmentfault/pacman/errors"
3839
)
@@ -85,6 +86,7 @@ func (cc *CommentController) AddComment(ctx *gin.Context) {
8586
cc.rateLimitMiddleware.DuplicateRequestClear(ctx, rejectKey)
8687
}
8788
}()
89+
req.ObjectID = uid.DeShortID(req.ObjectID)
8890
req.UserID = middleware.GetLoginUserIDFromContext(ctx)
8991

9092
canList, err := cc.rankService.CheckOperationPermissions(ctx, req.UserID, []string{
@@ -243,6 +245,8 @@ func (cc *CommentController) GetCommentWithPage(ctx *gin.Context) {
243245
if handler.BindAndCheck(ctx, req) {
244246
return
245247
}
248+
req.ObjectID = uid.DeShortID(req.ObjectID)
249+
req.CommentID = uid.DeShortID(req.CommentID)
246250
req.UserID = middleware.GetLoginUserIDFromContext(ctx)
247251
canList, err := cc.rankService.CheckOperationPermissions(ctx, req.UserID, []string{
248252
permission.CommentEdit,

0 commit comments

Comments
 (0)