Skip to content

Commit 5b9049d

Browse files
committed
Add ShouldShowCommentType function when rendering pull review conversation
1 parent 0d65d71 commit 5b9049d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

routers/web/repo/pull_review.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package repo
66
import (
77
"errors"
88
"fmt"
9+
"math/big"
910
"net/http"
1011

1112
issues_model "code.gitea.io/gitea/models/issues"
@@ -198,6 +199,19 @@ func renderConversation(ctx *context.Context, comment *issues_model.Comment, ori
198199
ctx.ServerError("comment.Issue.LoadAttributes", err)
199200
return
200201
}
202+
203+
var hiddenCommentTypes *big.Int
204+
if ctx.IsSigned {
205+
val, err := user_model.GetUserSetting(ctx, ctx.Doer.ID, user_model.SettingsKeyHiddenCommentTypes)
206+
if err != nil {
207+
ctx.ServerError("GetUserSetting", err)
208+
return
209+
}
210+
hiddenCommentTypes, _ = new(big.Int).SetString(val, 10) // we can safely ignore the failed conversion here
211+
}
212+
ctx.Data["ShouldShowCommentType"] = func(commentType issues_model.CommentType) bool {
213+
return hiddenCommentTypes == nil || hiddenCommentTypes.Bit(int(commentType)) == 0
214+
}
201215
ctx.Data["Issue"] = comment.Issue
202216
ctx.Data["IsIssue"] = true
203217
ctx.Data["Comments"] = comment.Issue.Comments

0 commit comments

Comments
 (0)