Skip to content

Commit f2844b7

Browse files
sotho6543zeripath
authored
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]>
1 parent 39ef6f8 commit f2844b7

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

modules/convert/pull_review.go

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

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

88-
auth := false
89-
if doer != nil {
90-
auth = doer.IsAdmin || doer.ID == review.ReviewerID
91-
}
92-
9388
for _, lines := range review.CodeComments {
9489
for _, comments := range lines {
9590
for _, comment := range comments {
91+
auth := false
92+
if doer != nil {
93+
auth = doer.IsAdmin || doer.ID == comment.Poster.ID
94+
}
9695
apiComment := &api.PullReviewComment{
9796
ID: comment.ID,
9897
Body: comment.Content,
99-
Reviewer: ToUser(review.Reviewer, doer != nil, auth),
100-
ReviewID: review.ID,
98+
Reviewer: ToUser(comment.Poster, doer != nil, auth),
99+
ReviewID: comment.PosterID,
101100
Created: comment.CreatedUnix.AsTime(),
102101
Updated: comment.UpdatedUnix.AsTime(),
103102
Path: comment.TreePath,

0 commit comments

Comments
 (0)