Add ShouldShowCommentType function when rendering pull review conversation

This commit is contained in:
RedCocoon 2024-11-04 19:04:34 +08:00
parent 0d65d7140b
commit 5b9049dec0

View File

@ -6,6 +6,7 @@ package repo
import (
"errors"
"fmt"
"math/big"
"net/http"
issues_model "code.gitea.io/gitea/models/issues"
@ -198,6 +199,19 @@ func renderConversation(ctx *context.Context, comment *issues_model.Comment, ori
ctx.ServerError("comment.Issue.LoadAttributes", err)
return
}
var hiddenCommentTypes *big.Int
if ctx.IsSigned {
val, err := user_model.GetUserSetting(ctx, ctx.Doer.ID, user_model.SettingsKeyHiddenCommentTypes)
if err != nil {
ctx.ServerError("GetUserSetting", err)
return
}
hiddenCommentTypes, _ = new(big.Int).SetString(val, 10) // we can safely ignore the failed conversion here
}
ctx.Data["ShouldShowCommentType"] = func(commentType issues_model.CommentType) bool {
return hiddenCommentTypes == nil || hiddenCommentTypes.Bit(int(commentType)) == 0
}
ctx.Data["Issue"] = comment.Issue
ctx.Data["IsIssue"] = true
ctx.Data["Comments"] = comment.Issue.Comments