Wrong user returned in API: GET /repos/{owner}/{repo}/pulls/{index}/reviews/{id}/comments #7056

Closed
opened 2025-11-02 07:14:35 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @sotho on GitHub (Mar 23, 2021).

Description

I use the API to download the comments of a review.
In the returned json all comments have the the same user, although the comments were done by different users (as can be seen in the web frontend).

In modules/convert/pull_review.go ToPullReviewCommentList uses the reviewer, but I think it should use the poster of the comment. This fixes it for me:

--- a/modules/convert/pull_review.go
+++ b/modules/convert/pull_review.go
@@ -94,7 +94,7 @@ func ToPullReviewCommentList(review *models.Review, doer *models.User) ([]*api.P
                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(),
Originally created by @sotho on GitHub (Mar 23, 2021). - Gitea version (or commit ref): v1.13.5 - Git version: 2.29.2 - Operating system: Debian/buster - Release from https://dl.gitea.io/gitea/1.13.5/gitea-1.13.5-linux-amd64 - Also tried self-built v1.13.5 - Database (use `[x]`): - [ ] PostgreSQL - [X] MySQL - [ ] MSSQL - [ ] SQLite ## Description I use the API to download the comments of a review. In the returned json all comments have the the same user, although the comments were done by different users (as can be seen in the web frontend). In modules/convert/pull_review.go ToPullReviewCommentList uses the reviewer, but I think it should use the poster of the comment. This fixes it for me: --- a/modules/convert/pull_review.go +++ b/modules/convert/pull_review.go @@ -94,7 +94,7 @@ func ToPullReviewCommentList(review *models.Review, doer *models.User) ([]*api.P 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(),
GiteaMirror added the type/bug label 2025-11-02 07:14:35 -06:00
Author
Owner

@a1012112796 commented on GitHub (Mar 24, 2021):

@sotho Hello, Thanks for your response, would you please send a pull request to fix it?Thanks.

@a1012112796 commented on GitHub (Mar 24, 2021): @sotho Hello, Thanks for your response, would you please send a pull request to fix it?Thanks.
Author
Owner

@sotho commented on GitHub (Mar 24, 2021):

Pull request #15139 opened

@sotho commented on GitHub (Mar 24, 2021): Pull request #15139 opened
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#7056