A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.
fix(vote): check vote permission wrong
LinkinStar22aa8e427125
diff --git a/internal/service/rank/rank_service.go b/internal/service/rank/rank_service.goindex 99a7024b..4b105ea7 100644--- a/internal/service/rank/rank_service.go+++ b/internal/service/rank/rank_service.go@@ -150,16 +150,10 @@ func (rs *RankService) CheckVotePermission(ctx context.Context, userID, objectIDif !exist {return can, nil}- // TODO administrator have all permissions- //if userInfo.IsAdmin {- // return true, nil- //}-objectInfo, err := rs.objectInfoService.GetInfo(ctx, objectID)if err != nil {return can, err}-action := ""switch objectInfo.ObjectType {case constant.QuestionObjectType:@@ -181,6 +175,11 @@ func (rs *RankService) CheckVotePermission(ctx context.Context, userID, objectIDaction = permission.CommentVoteDown}}+ powerMapping := rs.getUserPowerMapping(ctx, userID)+ if powerMapping[action] {+ return true, nil+ }+meetRank := rs.checkUserRank(ctx, userInfo.ID, userInfo.Rank, PermissionPrefix+action)return meetRank, nil}