From 3558310c1fe7c3cd11635d1d0b3dd7dfe79d1add Mon Sep 17 00:00:00 2001 From: sotho Date: Fri, 26 Mar 2021 04:20:52 +0100 Subject: [PATCH] Fix wrong user returned in API (#15139) (#15151) The API call: GET /repos/{owner}/{repo}/pulls/{index}/reviews/{id}/comments returns always the reviewer, but should return the poster. Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: zeripath --- modules/convert/pull_review.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/modules/convert/pull_review.go b/modules/convert/pull_review.go index d1d6e767d..418cb711d 100644 --- a/modules/convert/pull_review.go +++ b/modules/convert/pull_review.go @@ -85,18 +85,17 @@ func ToPullReviewCommentList(review *models.Review, doer *models.User) ([]*api.P apiComments := make([]*api.PullReviewComment, 0, len(review.CodeComments)) - auth := false - if doer != nil { - auth = doer.IsAdmin || doer.ID == review.ReviewerID - } - for _, lines := range review.CodeComments { for _, comments := range lines { for _, comment := range comments { + auth := false + if doer != nil { + auth = doer.IsAdmin || doer.ID == comment.Poster.ID + } apiComment := &api.PullReviewComment{ ID: comment.ID, Body: comment.Content, - Reviewer: ToUser(review.Reviewer, doer != nil, auth), + Reviewer: ToUser(comment.Poster, doer != nil, auth), ReviewID: review.ID, Created: comment.CreatedUnix.AsTime(), Updated: comment.UpdatedUnix.AsTime(),