Skip to content

Commit 5583c03

Browse files
committed
Expose resolver via API
* Add a new field to the API to expose the "resolver" of a comment/ conversation. This is not available in the GitHub API v3. * Extend struct to contain "Resolver". Might be empty (nil). * Rename "Reviewer" to "Poster" in PullReviewComment to make it clear this is the person posting a comment. The API is unchanged ('user'). * Only the first comment of a conversation might have a resolver, the others seem to be always nil.
1 parent dc56fb7 commit 5583c03

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

integrations/api_pull_review_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func TestAPIPullReview(t *testing.T) {
6666
var reviewComments []*api.PullReviewComment
6767
DecodeJSON(t, resp, &reviewComments)
6868
assert.Len(t, reviewComments, 1)
69-
assert.EqualValues(t, "Ghost", reviewComments[0].Reviewer.UserName)
69+
assert.EqualValues(t, "Ghost", reviewComments[0].Poster.UserName)
7070
assert.EqualValues(t, "a review from a deleted user", reviewComments[0].Body)
7171
assert.EqualValues(t, comment.ID, reviewComments[0].ID)
7272
assert.EqualValues(t, comment.UpdatedUnix, reviewComments[0].Updated.Unix())

modules/convert/pull_review.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,19 @@ func ToPullReviewCommentList(review *models.Review, doer *models.User) ([]*api.P
8888
for _, lines := range review.CodeComments {
8989
for _, comments := range lines {
9090
for _, comment := range comments {
91-
auth := false
91+
authPoster := false
9292
if doer != nil {
93-
auth = doer.IsAdmin || doer.ID == comment.Poster.ID
93+
authPoster = doer.IsAdmin || doer.ID == comment.Poster.ID
94+
}
95+
authResolver := false
96+
if doer != nil {
97+
authResolver = doer.IsAdmin || (comment.ResolveDoer != nil && doer.ID == comment.ResolveDoer.ID)
9498
}
9599
apiComment := &api.PullReviewComment{
96100
ID: comment.ID,
97101
Body: comment.Content,
98-
Reviewer: ToUser(comment.Poster, doer != nil, auth),
102+
Poster: ToUser(comment.Poster, doer != nil, authPoster),
103+
Resolver: ToUser(comment.ResolveDoer, doer != nil, authResolver),
99104
ReviewID: review.ID,
100105
Created: comment.CreatedUnix.AsTime(),
101106
Updated: comment.UpdatedUnix.AsTime(),

modules/structs/pull_review.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ type PullReview struct {
4949
type PullReviewComment struct {
5050
ID int64 `json:"id"`
5151
Body string `json:"body"`
52-
Reviewer *User `json:"user"`
52+
Poster *User `json:"user"`
53+
Resolver *User `json:"resolver"`
5354
ReviewID int64 `json:"pull_request_review_id"`
5455

5556
// swagger:strfmt date-time

templates/swagger/v1_json.tmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15455,6 +15455,9 @@
1545515455
"type": "string",
1545615456
"x-go-name": "HTMLPullURL"
1545715457
},
15458+
"resolver": {
15459+
"$ref": "#/definitions/User"
15460+
},
1545815461
"updated_at": {
1545915462
"type": "string",
1546015463
"format": "date-time",

0 commit comments

Comments
 (0)