Skip to content

Commit

Permalink
Fix wrong user returned in API (go-gitea#15139) (go-gitea#15150)
Browse files Browse the repository at this point in the history
* Fix wrong user returned in API (go-gitea#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>
  • Loading branch information
3 people authored Mar 26, 2021
1 parent 6dfa92b commit 4f47bf5
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions modules/convert/pull_review.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit 4f47bf5

Please sign in to comment.