diff options
author | sotho | 2021-03-26 07:01:32 +0100 |
---|---|---|
committer | GitHub | 2021-03-26 08:01:32 +0200 |
commit | 4f47bf5346db1d2b3155b6136309b0fa80a3a517 (patch) | |
tree | 87092f755bbfef4be6bf2aae1cc4299cdd9febfa | |
parent | 6dfa92bb1ca97d4e93e07dd5c289a8035761d89c (diff) |
Fix wrong user returned in API (#15139) (#15150)
* Fix wrong user returned in API (#15139)
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 <art27@cantab.net>
* rm regression
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: zeripath <art27@cantab.net>
-rw-r--r-- | modules/convert/pull_review.go | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/modules/convert/pull_review.go b/modules/convert/pull_review.go index 032d3617f..d98651a39 100644 --- a/modules/convert/pull_review.go +++ b/modules/convert/pull_review.go @@ -83,18 +83,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(), |