mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-03 21:08:25 +00:00 
			
		
		
		
	* 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> * rm regression Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: zeripath <art27@cantab.net>
This commit is contained in:
		@@ -83,18 +83,17 @@ func ToPullReviewCommentList(review *models.Review, doer *models.User) ([]*api.P
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	apiComments := make([]*api.PullReviewComment, 0, len(review.CodeComments))
 | 
						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 _, lines := range review.CodeComments {
 | 
				
			||||||
		for _, comments := range lines {
 | 
							for _, comments := range lines {
 | 
				
			||||||
			for _, comment := range comments {
 | 
								for _, comment := range comments {
 | 
				
			||||||
 | 
									auth := false
 | 
				
			||||||
 | 
									if doer != nil {
 | 
				
			||||||
 | 
										auth = doer.IsAdmin || doer.ID == comment.Poster.ID
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
				apiComment := &api.PullReviewComment{
 | 
									apiComment := &api.PullReviewComment{
 | 
				
			||||||
					ID:           comment.ID,
 | 
										ID:           comment.ID,
 | 
				
			||||||
					Body:         comment.Content,
 | 
										Body:         comment.Content,
 | 
				
			||||||
					Reviewer:     ToUser(review.Reviewer, doer != nil, auth),
 | 
										Reviewer:     ToUser(comment.Poster, doer != nil, auth),
 | 
				
			||||||
					ReviewID:     review.ID,
 | 
										ReviewID:     review.ID,
 | 
				
			||||||
					Created:      comment.CreatedUnix.AsTime(),
 | 
										Created:      comment.CreatedUnix.AsTime(),
 | 
				
			||||||
					Updated:      comment.UpdatedUnix.AsTime(),
 | 
										Updated:      comment.UpdatedUnix.AsTime(),
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user