This is an automated email from the ASF dual-hosted git repository. LinkinStars pushed a commit to branch fix/2.0.2/user in repository https://gitbox.apache.org/repos/asf/answer.git
commit 540f771b4463e0cc731aa02a3163d6bf484a9195 Author: LinkinStars <[email protected]> AuthorDate: Wed Jul 8 12:27:43 2026 +0800 fix: enhance answer visibility checks for user permissions --- internal/service/content/answer_service.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/service/content/answer_service.go b/internal/service/content/answer_service.go index 25b0050e..bda7b582 100644 --- a/internal/service/content/answer_service.go +++ b/internal/service/content/answer_service.go @@ -554,12 +554,18 @@ func (as *AnswerService) Get(ctx context.Context, answerID, loginUserID string, if !exist { return nil, nil, false, errors.NotFound(reason.AnswerNotFound) } + if (question.Status == entity.QuestionStatusDeleted || question.Status == entity.QuestionStatusPending || question.Show == entity.QuestionHide) && !isAdminModerator && question.UserID != loginUserID { return nil, nil, false, errors.NotFound(reason.AnswerNotFound) } + if (answerInfo.Status == entity.AnswerStatusDeleted || + answerInfo.Status == entity.AnswerStatusPending) && + !isAdminModerator && answerInfo.UserID != loginUserID { + return nil, nil, false, errors.NotFound(reason.AnswerNotFound) + } info := as.ShowFormat(ctx, answerInfo) // todo questionFunc questionInfo, err := as.questionCommon.Info(ctx, answerInfo.QuestionID, loginUserID)
