This is an automated email from the ASF dual-hosted git repository.

LinkinStars pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/answer.git

commit c589b59dd5f16d59b389ec4da8f8e1a97ac8ef04
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)

Reply via email to