Skip to content

Commit 4f47bf5

Browse files
sotho6543zeripath
authored
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 <[email protected]> Co-authored-by: zeripath <[email protected]> * rm regression Co-authored-by: 6543 <[email protected]> Co-authored-by: zeripath <[email protected]>
1 parent 6dfa92b commit 4f47bf5

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

modules/convert/pull_review.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,17 @@ func ToPullReviewCommentList(review *models.Review, doer *models.User) ([]*api.P
8383

8484
apiComments := make([]*api.PullReviewComment, 0, len(review.CodeComments))
8585

86-
auth := false
87-
if doer != nil {
88-
auth = doer.IsAdmin || doer.ID == review.ReviewerID
89-
}
90-
9186
for _, lines := range review.CodeComments {
9287
for _, comments := range lines {
9388
for _, comment := range comments {
89+
auth := false
90+
if doer != nil {
91+
auth = doer.IsAdmin || doer.ID == comment.Poster.ID
92+
}
9493
apiComment := &api.PullReviewComment{
9594
ID: comment.ID,
9695
Body: comment.Content,
97-
Reviewer: ToUser(review.Reviewer, doer != nil, auth),
96+
Reviewer: ToUser(comment.Poster, doer != nil, auth),
9897
ReviewID: review.ID,
9998
Created: comment.CreatedUnix.AsTime(),
10099
Updated: comment.UpdatedUnix.AsTime(),

0 commit comments

Comments
 (0)