summaryrefslogtreecommitdiffstats
path: root/modules/convert
diff options
context:
space:
mode:
authorsotho <alex@segv.de>2021-03-24 21:26:15 +0100
committerGitHub <noreply@github.com>2021-03-24 21:26:15 +0100
commitf2844b75831c9e05eae20c18116f104d3de7ee86 (patch)
tree7a66d5432a30304d70d4ee2f8c9f44d092f12ded /modules/convert
parent39ef6f83d50e9e641bf36342c532e8a4ad7cf3f7 (diff)
downloadgitea-f2844b75831c9e05eae20c18116f104d3de7ee86.tar.gz
gitea-f2844b75831c9e05eae20c18116f104d3de7ee86.zip
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>
Diffstat (limited to 'modules/convert')
-rw-r--r--modules/convert/pull_review.go13
1 files changed, 6 insertions, 7 deletions
diff --git a/modules/convert/pull_review.go b/modules/convert/pull_review.go
index d1d6e767d4..067831cd77 100644
--- a/modules/convert/pull_review.go
+++ b/modules/convert/pull_review.go
@@ -85,19 +85,18 @@ 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),
- ReviewID: review.ID,
+ Reviewer: ToUser(comment.Poster, doer != nil, auth),
+ ReviewID: comment.PosterID,
Created: comment.CreatedUnix.AsTime(),
Updated: comment.UpdatedUnix.AsTime(),
Path: comment.TreePath,