diff options
author | Jason Song <i@wolfogre.com> | 2023-04-23 23:04:23 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-23 11:04:23 -0400 |
commit | 066af372e34acd40ff6e0d1fb78f48b40c3c7fa9 (patch) | |
tree | a1406fbed0adeb0956c292480ed56f5c685f80f9 /models | |
parent | 67da4c1b259e9d000535f35974cf12051c1c42b5 (diff) | |
download | gitea-066af372e34acd40ff6e0d1fb78f48b40c3c7fa9.tar.gz gitea-066af372e34acd40ff6e0d1fb78f48b40c3c7fa9.zip |
Load reviewer for comments when dismissing a review (#24281)
If a comment dismisses a review, we need to load the reviewer to show
whose review has been dismissed.
Related to:
https://github.com/go-gitea/gitea/blob/20b6ae0e5399cfc22c6a0989d8e520194e920bdd/templates/repo/issue/view_content/comments.tmpl#L765-L770
We don't need `.Review.Reviewer` for all comments, because
"dismissing" doesn't happen often, or we would have already received
error reports.
Diffstat (limited to 'models')
-rw-r--r-- | models/issues/comment_list.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/models/issues/comment_list.go b/models/issues/comment_list.go index 0411d44531..477337443d 100644 --- a/models/issues/comment_list.go +++ b/models/issues/comment_list.go @@ -56,7 +56,7 @@ func (comments CommentList) getLabelIDs() []int64 { return ids.Values() } -func (comments CommentList) loadLabels(ctx context.Context) error { //nolint +func (comments CommentList) loadLabels(ctx context.Context) error { if len(comments) == 0 { return nil } @@ -415,7 +415,7 @@ func (comments CommentList) getReviewIDs() []int64 { return ids.Values() } -func (comments CommentList) loadReviews(ctx context.Context) error { //nolint +func (comments CommentList) loadReviews(ctx context.Context) error { if len(comments) == 0 { return nil } @@ -453,6 +453,14 @@ func (comments CommentList) loadReviews(ctx context.Context) error { //nolint for _, comment := range comments { comment.Review = reviews[comment.ReviewID] + + // If the comment dismisses a review, we need to load the reviewer to show whose review has been dismissed. + // Otherwise, the reviewer is the poster of the comment, so we don't need to load it. + if comment.Type == CommentTypeDismissReview { + if err := comment.Review.LoadReviewer(ctx); err != nil { + return err + } + } } return nil } |