webhooks: Add ReviewBoard integration.

This commit is contained in:
Eeshan Garg 2018-11-01 17:26:22 -02:30 committed by Tim Abbott
parent a942732d83
commit 41c0e9ba47
13 changed files with 1254 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

View File

@ -344,6 +344,7 @@ WEBHOOK_INTEGRATIONS = [
WebhookIntegration('pingdom', ['monitoring']),
WebhookIntegration('pivotal', ['project-management'], display_name='Pivotal Tracker'),
WebhookIntegration('raygun', ['monitoring'], display_name="Raygun"),
WebhookIntegration('reviewboard', ['version-control'], display_name="ReviewBoard"),
WebhookIntegration('semaphore', ['continuous-integration', 'deployment'], stream_name='builds'),
WebhookIntegration('sentry', ['monitoring']),
WebhookIntegration('slack', ['communication']),

View File

View File

@ -0,0 +1,17 @@
Get ReviewBoard notifications in Zulip!
1. {!create-stream.md!}
1. {!create-bot-construct-url-indented.md!}
1. On your ReviewBoard **Dashboard**, click your team's name in the top-right
corner, and click **Team administration**. Select **WebHooks** on the
left sidebar, and click **+ Create a WebHook**.
1. Make sure the **Enabled** option is checked. Set **URL** to the URL constucted
above, and select the events you'd like to be notified about. Set **Encoding**
to **JSON**, and click **Create WebHook**.
{!congrats.md!}
![](/static/images/integrations/reviewboard/001.png)

View File

@ -0,0 +1,219 @@
{
"diff_comments":[
{
"issue_opened":false,
"interfilediff":null,
"num_lines":1,
"links":{
"self":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/reviews/651728/replies/651732/diff-comments/778505/",
"method":"GET"
},
"update":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/reviews/651728/replies/651732/diff-comments/778505/",
"method":"PUT"
},
"user":{
"href":"https://rbcommons.com/s/zulip/api/users/drsbgarg/",
"method":"GET",
"title":"drsbgarg"
},
"reply_to":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/reviews/651728/diff-comments/778500/",
"method":"GET",
"title":"I think we should get rid of this extra whitespace here"
},
"delete":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/reviews/651728/replies/651732/diff-comments/778505/",
"method":"DELETE"
},
"filediff":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/diffs/1/files/6128836/",
"method":"GET",
"title":"AddSpaces.java (PRE-CREATION) -> AddSpaces.java (dc54788b2bf0324a3228faa7224c3c523582d9f6)"
}
},
"timestamp":"2018-10-26T15:57:39Z",
"text_type":"markdown",
"public":true,
"text":"I agree, I'll push another diff addressing that. Thanks for the review! :)",
"first_line":81,
"extra_data":{
},
"id":778505,
"issue_status":""
}
],
"file_attachment_comments":[
],
"general_comments":[
],
"screenshot_comments":[
],
"reply":{
"body_top":"",
"extra_data":{
},
"links":{
"diff_comments":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/reviews/651728/replies/651732/diff-comments/",
"method":"GET"
},
"file_attachment_comments":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/reviews/651728/replies/651732/file-attachment-comments/",
"method":"GET"
},
"self":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/reviews/651728/replies/651732/",
"method":"GET"
},
"update":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/reviews/651728/replies/651732/",
"method":"PUT"
},
"general_comments":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/reviews/651728/replies/651732/general-comments/",
"method":"GET"
},
"screenshot_comments":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/reviews/651728/replies/651732/screenshot-comments/",
"method":"GET"
},
"user":{
"href":"https://rbcommons.com/s/zulip/api/users/drsbgarg/",
"method":"GET",
"title":"drsbgarg"
},
"delete":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/reviews/651728/replies/651732/",
"method":"DELETE"
}
},
"timestamp":"2018-10-26T15:57:39Z",
"public":true,
"text_type":null,
"body_bottom":"",
"body_top_text_type":"plain",
"id":651732,
"body_bottom_text_type":"plain"
},
"review_request":{
"status":"pending",
"last_updated":"2018-10-26T15:57:39Z",
"target_people":[
{
"href":"https://rbcommons.com/s/zulip/api/users/drsbgarg/",
"method":"GET",
"title":"drsbgarg"
}
],
"depends_on":[
],
"description_text_type":"plain",
"issue_resolved_count":0,
"commit_id":"4f8a093f7046fcc58b0826d21586d1b537b0112b",
"ship_it_count":0,
"close_description_text_type":"plain",
"id":1,
"links":{
"diffs":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/diffs/",
"method":"GET"
},
"latest_diff":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/diffs/1/",
"method":"GET"
},
"repository":{
"href":"https://rbcommons.com/s/zulip/api/repositories/2147/",
"method":"GET",
"title":"Scheduler"
},
"screenshots":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/screenshots/",
"method":"GET"
},
"self":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/",
"method":"GET"
},
"status_updates":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/status-updates/",
"method":"GET"
},
"update":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/",
"method":"PUT"
},
"last_update":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/last-update/",
"method":"GET"
},
"reviews":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/reviews/",
"method":"GET"
},
"file_attachments":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/file-attachments/",
"method":"GET"
},
"draft":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/draft/",
"method":"GET"
},
"diff_context":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/diff-context/",
"method":"GET"
},
"submitter":{
"href":"https://rbcommons.com/s/zulip/api/users/eeshangarg/",
"method":"GET",
"title":"eeshangarg"
},
"changes":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/changes/",
"method":"GET"
},
"delete":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/",
"method":"DELETE"
}
},
"issue_dropped_count":0,
"bugs_closed":[
],
"testing_done":"This was tested thoroughly",
"branch":"master",
"text_type":null,
"time_added":"2018-10-26T15:24:18Z",
"extra_data":{
"calculated_trophies":true
},
"public":true,
"issue_verifying_count":0,
"close_description":null,
"blocks":[
],
"description":"Initial commit (first iteration)",
"testing_done_text_type":"markdown",
"issue_open_count":0,
"approved":false,
"url":"/s/zulip/r/1/",
"absolute_url":"https://rbcommons.com/s/zulip/r/1/",
"target_groups":[
],
"summary":"Initial commit (first iteration)",
"changenum":null,
"approval_failure":"The review request has not been marked \"Ship It!\""
},
"event":"reply_published"
}

View File

@ -0,0 +1,212 @@
{
"diff_comments":[
{
"issue_opened":false,
"interfilediff":null,
"num_lines":1,
"links":{
"self":{
"href":"https://rbcommons.com",
"method":"GET"
},
"user":{
"href":"https://rbcommons.com/s/zulip/api/users/eeshangarg/",
"method":"GET",
"title":"eeshangarg"
},
"filediff":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/diffs/1/files/6128836/",
"method":"GET",
"title":"AddSpaces.java (PRE-CREATION) -> AddSpaces.java (dc54788b2bf0324a3228faa7224c3c523582d9f6)"
}
},
"timestamp":"2018-10-26T15:52:29Z",
"id":778500,
"issue_status":"",
"text":"I think we should get rid of this extra whitespace here",
"first_line":81,
"extra_data":{
"require_verification":false
},
"public":true,
"text_type":"markdown"
}
],
"file_attachment_comments":[
],
"review":{
"body_top":"Left some minor comments, thanks!",
"ship_it":false,
"extra_data":{
},
"links":{
"diff_comments":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/reviews/651728/diff-comments/",
"method":"GET"
},
"file_attachment_comments":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/reviews/651728/file-attachment-comments/",
"method":"GET"
},
"self":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/reviews/651728/",
"method":"GET"
},
"update":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/reviews/651728/",
"method":"PUT"
},
"general_comments":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/reviews/651728/general-comments/",
"method":"GET"
},
"screenshot_comments":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/reviews/651728/screenshot-comments/",
"method":"GET"
},
"user":{
"href":"https://rbcommons.com/s/zulip/api/users/eeshangarg/",
"method":"GET",
"title":"eeshangarg"
},
"replies":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/reviews/651728/replies/",
"method":"GET"
},
"delete":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/reviews/651728/",
"method":"DELETE"
}
},
"timestamp":"2018-10-26T15:52:29Z",
"absolute_url":"https://rbcommons.com/s/zulip/r/1/#review651728",
"public":true,
"text_type":null,
"body_bottom":"",
"body_top_text_type":"markdown",
"id":651728,
"body_bottom_text_type":"plain"
},
"general_comments":[
],
"screenshot_comments":[
],
"review_request":{
"status":"pending",
"last_updated":"2018-10-26T15:52:29Z",
"target_people":[
{
"href":"https://rbcommons.com/s/zulip/api/users/drsbgarg/",
"method":"GET",
"title":"drsbgarg"
}
],
"depends_on":[
],
"description_text_type":"plain",
"issue_resolved_count":0,
"commit_id":"4f8a093f7046fcc58b0826d21586d1b537b0112b",
"ship_it_count":0,
"close_description_text_type":"plain",
"id":1,
"links":{
"diffs":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/diffs/",
"method":"GET"
},
"latest_diff":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/diffs/1/",
"method":"GET"
},
"repository":{
"href":"https://rbcommons.com/s/zulip/api/repositories/2147/",
"method":"GET",
"title":"Scheduler"
},
"screenshots":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/screenshots/",
"method":"GET"
},
"self":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/",
"method":"GET"
},
"status_updates":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/status-updates/",
"method":"GET"
},
"update":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/",
"method":"PUT"
},
"last_update":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/last-update/",
"method":"GET"
},
"reviews":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/reviews/",
"method":"GET"
},
"file_attachments":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/file-attachments/",
"method":"GET"
},
"draft":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/draft/",
"method":"GET"
},
"diff_context":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/diff-context/",
"method":"GET"
},
"submitter":{
"href":"https://rbcommons.com/s/zulip/api/users/eeshangarg/",
"method":"GET",
"title":"eeshangarg"
},
"changes":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/changes/",
"method":"GET"
},
"delete":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/",
"method":"DELETE"
}
},
"issue_dropped_count":0,
"bugs_closed":[
],
"testing_done":"This was tested thoroughly",
"branch":"master",
"text_type":null,
"time_added":"2018-10-26T15:24:18Z",
"extra_data":{
"calculated_trophies":true
},
"public":true,
"issue_verifying_count":0,
"close_description":null,
"blocks":[
],
"description":"Initial commit (first iteration)",
"testing_done_text_type":"markdown",
"issue_open_count":0,
"approved":false,
"url":"/s/zulip/r/1/",
"absolute_url":"https://rbcommons.com/s/zulip/r/1/",
"target_groups":[
],
"summary":"Initial commit (first iteration)",
"changenum":null,
"approval_failure":"The review request has not been marked \"Ship It!\""
},
"event":"review_published"
}

View File

@ -0,0 +1,159 @@
{
"close_type":"submitted",
"review_request":{
"status":"submitted",
"last_updated":"2018-10-26T15:41:55Z",
"target_people":[
{
"href":"https://rbcommons.com/s/zulip/api/users/drsbgarg/",
"method":"GET",
"title":"drsbgarg"
}
],
"depends_on":[
],
"description_text_type":"plain",
"issue_resolved_count":0,
"commit_id":"4f8a093f7046fcc58b0826d21586d1b537b0112b",
"ship_it_count":0,
"close_description_text_type":"plain",
"id":1,
"links":{
"diffs":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/diffs/",
"method":"GET"
},
"latest_diff":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/diffs/1/",
"method":"GET"
},
"repository":{
"href":"https://rbcommons.com/s/zulip/api/repositories/2147/",
"method":"GET",
"title":"Scheduler"
},
"screenshots":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/screenshots/",
"method":"GET"
},
"self":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/",
"method":"GET"
},
"status_updates":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/status-updates/",
"method":"GET"
},
"update":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/",
"method":"PUT"
},
"last_update":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/last-update/",
"method":"GET"
},
"reviews":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/reviews/",
"method":"GET"
},
"file_attachments":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/file-attachments/",
"method":"GET"
},
"draft":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/draft/",
"method":"GET"
},
"diff_context":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/diff-context/",
"method":"GET"
},
"submitter":{
"href":"https://rbcommons.com/s/zulip/api/users/eeshangarg/",
"method":"GET",
"title":"eeshangarg"
},
"changes":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/changes/",
"method":"GET"
},
"delete":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/",
"method":"DELETE"
}
},
"issue_dropped_count":0,
"bugs_closed":[
],
"testing_done":"This was tested thoroughly",
"branch":"master",
"text_type":null,
"time_added":"2018-10-26T15:24:18Z",
"extra_data":{
"calculated_trophies":true
},
"public":true,
"issue_verifying_count":0,
"close_description":"",
"blocks":[
],
"description":"Initial commit (first iteration)",
"testing_done_text_type":"markdown",
"issue_open_count":0,
"approved":false,
"url":"/s/zulip/r/1/",
"absolute_url":"https://rbcommons.com/s/zulip/r/1/",
"target_groups":[
],
"summary":"Initial commit (first iteration)",
"changenum":null,
"approval_failure":"The review request has not been marked \"Ship It!\""
},
"event":"review_request_closed",
"closed_by":{
"username":"eeshangarg",
"first_name":"Eeshan",
"last_name":"Garg",
"links":{
"api_tokens":{
"href":"https://rbcommons.com/s/zulip/api/users/eeshangarg/api-tokens/",
"method":"GET"
},
"self":{
"href":"https://rbcommons.com/s/zulip/api/users/eeshangarg/",
"method":"GET"
},
"archived_review_requests":{
"href":"https://rbcommons.com/s/zulip/api/users/eeshangarg/archived-review-requests/",
"method":"GET"
},
"user_file_attachments":{
"href":"https://rbcommons.com/s/zulip/api/users/eeshangarg/user-file-attachments/",
"method":"GET"
},
"muted_review_requests":{
"href":"https://rbcommons.com/s/zulip/api/users/eeshangarg/muted-review-requests/",
"method":"GET"
},
"watched":{
"href":"https://rbcommons.com/s/zulip/api/users/eeshangarg/watched/",
"method":"GET"
}
},
"url":"/s/zulip/users/eeshangarg/",
"is_active":true,
"fullname":"Eeshan Garg",
"email":"jerryguitarist@gmail.com",
"avatar_url":"https://secure.gravatar.com/avatar/cd181af88d928dab53c55600c9f7551d?s=48&d=mm",
"avatar_urls":{
"1x":"https://secure.gravatar.com/avatar/cd181af88d928dab53c55600c9f7551d?s=48&d=mm",
"3x":"https://secure.gravatar.com/avatar/cd181af88d928dab53c55600c9f7551d?s=144&d=mm",
"2x":"https://secure.gravatar.com/avatar/cd181af88d928dab53c55600c9f7551d?s=96&d=mm"
},
"id":11032
}
}

View File

@ -0,0 +1,117 @@
{
"review_request":{
"status":"pending",
"last_updated":"2018-10-26T15:39:46Z",
"target_people":[
{
"href":"https://rbcommons.com/s/zulip/api/users/drsbgarg/",
"method":"GET",
"title":"drsbgarg"
}
],
"depends_on":[
],
"description_text_type":"plain",
"issue_resolved_count":0,
"commit_id":"0c694b62d4cfd159e1b94b9368bc573338c7c77a",
"ship_it_count":0,
"close_description_text_type":"plain",
"id":2,
"links":{
"diffs":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/2/diffs/",
"method":"GET"
},
"latest_diff":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/2/diffs/1/",
"method":"GET"
},
"repository":{
"href":"https://rbcommons.com/s/zulip/api/repositories/2147/",
"method":"GET",
"title":"Scheduler"
},
"screenshots":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/2/screenshots/",
"method":"GET"
},
"self":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/2/",
"method":"GET"
},
"status_updates":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/2/status-updates/",
"method":"GET"
},
"update":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/2/",
"method":"PUT"
},
"last_update":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/2/last-update/",
"method":"GET"
},
"reviews":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/2/reviews/",
"method":"GET"
},
"file_attachments":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/2/file-attachments/",
"method":"GET"
},
"draft":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/2/draft/",
"method":"GET"
},
"diff_context":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/2/diff-context/",
"method":"GET"
},
"submitter":{
"href":"https://rbcommons.com/s/zulip/api/users/eeshangarg/",
"method":"GET",
"title":"eeshangarg"
},
"changes":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/2/changes/",
"method":"GET"
},
"delete":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/2/",
"method":"DELETE"
}
},
"issue_dropped_count":0,
"bugs_closed":[
],
"testing_done":"This was tested thoroughly.",
"branch":"master",
"text_type":null,
"time_added":"2018-10-26T15:39:46Z",
"extra_data":{
"calculated_trophies":true
},
"public":true,
"issue_verifying_count":0,
"close_description":null,
"blocks":[
],
"description":"Initial commit",
"testing_done_text_type":"markdown",
"issue_open_count":0,
"approved":false,
"url":"/s/zulip/r/2/",
"absolute_url":"https://rbcommons.com/s/zulip/r/2/",
"target_groups":[
],
"summary":"Initial commit",
"changenum":null,
"approval_failure":"The review request has not been marked \"Ship It!\""
},
"event":"review_request_published",
"is_new":true
}

View File

@ -0,0 +1,127 @@
{
"review_request":{
"status":"pending",
"last_updated":"2018-10-26T15:39:46Z",
"target_people":[
{
"href":"https://rbcommons.com/s/zulip/api/users/drsbgarg/",
"method":"GET",
"title":"drsbgarg"
},
{
"href":"https://rbcommons.com/s/zulip/api/users/johndoe/",
"method":"GET",
"title":"johndoe"
},
{
"href":"https://rbcommons.com/s/zulip/api/users/janedoe/",
"method":"GET",
"title":"janedoe"
}
],
"depends_on":[
],
"description_text_type":"plain",
"issue_resolved_count":0,
"commit_id":"0c694b62d4cfd159e1b94b9368bc573338c7c77a",
"ship_it_count":0,
"close_description_text_type":"plain",
"id":2,
"links":{
"diffs":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/2/diffs/",
"method":"GET"
},
"latest_diff":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/2/diffs/1/",
"method":"GET"
},
"repository":{
"href":"https://rbcommons.com/s/zulip/api/repositories/2147/",
"method":"GET",
"title":"Scheduler"
},
"screenshots":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/2/screenshots/",
"method":"GET"
},
"self":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/2/",
"method":"GET"
},
"status_updates":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/2/status-updates/",
"method":"GET"
},
"update":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/2/",
"method":"PUT"
},
"last_update":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/2/last-update/",
"method":"GET"
},
"reviews":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/2/reviews/",
"method":"GET"
},
"file_attachments":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/2/file-attachments/",
"method":"GET"
},
"draft":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/2/draft/",
"method":"GET"
},
"diff_context":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/2/diff-context/",
"method":"GET"
},
"submitter":{
"href":"https://rbcommons.com/s/zulip/api/users/eeshangarg/",
"method":"GET",
"title":"eeshangarg"
},
"changes":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/2/changes/",
"method":"GET"
},
"delete":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/2/",
"method":"DELETE"
}
},
"issue_dropped_count":0,
"bugs_closed":[
],
"testing_done":"This was tested thoroughly.",
"branch":"master",
"text_type":null,
"time_added":"2018-10-26T15:39:46Z",
"extra_data":{
"calculated_trophies":true
},
"public":true,
"issue_verifying_count":0,
"close_description":null,
"blocks":[
],
"description":"Initial commit",
"testing_done_text_type":"markdown",
"issue_open_count":0,
"approved":false,
"url":"/s/zulip/r/2/",
"absolute_url":"https://rbcommons.com/s/zulip/r/2/",
"target_groups":[
],
"summary":"Initial commit",
"changenum":null,
"approval_failure":"The review request has not been marked \"Ship It!\""
},
"event":"review_request_published",
"is_new":true
}

View File

@ -0,0 +1,158 @@
{
"reopened_by":{
"username":"eeshangarg",
"first_name":"Eeshan",
"last_name":"Garg",
"links":{
"api_tokens":{
"href":"https://rbcommons.com/s/zulip/api/users/eeshangarg/api-tokens/",
"method":"GET"
},
"self":{
"href":"https://rbcommons.com/s/zulip/api/users/eeshangarg/",
"method":"GET"
},
"archived_review_requests":{
"href":"https://rbcommons.com/s/zulip/api/users/eeshangarg/archived-review-requests/",
"method":"GET"
},
"user_file_attachments":{
"href":"https://rbcommons.com/s/zulip/api/users/eeshangarg/user-file-attachments/",
"method":"GET"
},
"muted_review_requests":{
"href":"https://rbcommons.com/s/zulip/api/users/eeshangarg/muted-review-requests/",
"method":"GET"
},
"watched":{
"href":"https://rbcommons.com/s/zulip/api/users/eeshangarg/watched/",
"method":"GET"
}
},
"url":"/s/zulip/users/eeshangarg/",
"is_active":true,
"fullname":"Eeshan Garg",
"email":"jerryguitarist@gmail.com",
"avatar_url":"https://secure.gravatar.com/avatar/cd181af88d928dab53c55600c9f7551d?s=48&d=mm",
"avatar_urls":{
"1x":"https://secure.gravatar.com/avatar/cd181af88d928dab53c55600c9f7551d?s=48&d=mm",
"3x":"https://secure.gravatar.com/avatar/cd181af88d928dab53c55600c9f7551d?s=144&d=mm",
"2x":"https://secure.gravatar.com/avatar/cd181af88d928dab53c55600c9f7551d?s=96&d=mm"
},
"id":11032
},
"review_request":{
"status":"pending",
"last_updated":"2018-10-26T15:45:49Z",
"target_people":[
{
"href":"https://rbcommons.com/s/zulip/api/users/drsbgarg/",
"method":"GET",
"title":"drsbgarg"
}
],
"depends_on":[
],
"description_text_type":"plain",
"issue_resolved_count":0,
"commit_id":"4f8a093f7046fcc58b0826d21586d1b537b0112b",
"ship_it_count":0,
"close_description_text_type":"plain",
"id":1,
"links":{
"diffs":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/diffs/",
"method":"GET"
},
"latest_diff":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/diffs/1/",
"method":"GET"
},
"repository":{
"href":"https://rbcommons.com/s/zulip/api/repositories/2147/",
"method":"GET",
"title":"Scheduler"
},
"screenshots":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/screenshots/",
"method":"GET"
},
"self":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/",
"method":"GET"
},
"status_updates":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/status-updates/",
"method":"GET"
},
"update":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/",
"method":"PUT"
},
"last_update":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/last-update/",
"method":"GET"
},
"reviews":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/reviews/",
"method":"GET"
},
"file_attachments":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/file-attachments/",
"method":"GET"
},
"draft":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/draft/",
"method":"GET"
},
"diff_context":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/diff-context/",
"method":"GET"
},
"submitter":{
"href":"https://rbcommons.com/s/zulip/api/users/eeshangarg/",
"method":"GET",
"title":"eeshangarg"
},
"changes":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/changes/",
"method":"GET"
},
"delete":{
"href":"https://rbcommons.com/s/zulip/api/review-requests/1/",
"method":"DELETE"
}
},
"issue_dropped_count":0,
"bugs_closed":[
],
"testing_done":"This was tested thoroughly",
"branch":"master",
"text_type":null,
"time_added":"2018-10-26T15:24:18Z",
"extra_data":{
"calculated_trophies":true
},
"public":true,
"issue_verifying_count":0,
"close_description":null,
"blocks":[
],
"description":"Initial commit (first iteration)",
"testing_done_text_type":"markdown",
"issue_open_count":0,
"approved":false,
"url":"/s/zulip/r/1/",
"absolute_url":"https://rbcommons.com/s/zulip/r/1/",
"target_groups":[
],
"summary":"Initial commit (first iteration)",
"changenum":null,
"approval_failure":"The review request has not been marked \"Ship It!\""
},
"event":"review_request_reopened"
}

View File

@ -0,0 +1,64 @@
# -*- coding: utf-8 -*-
from typing import Optional
from zerver.lib.test_classes import WebhookTestCase
class ReviewBoardHookTests(WebhookTestCase):
STREAM_NAME = 'reviewboard'
URL_TEMPLATE = '/api/v1/external/reviewboard?&api_key={api_key}&stream={stream}'
FIXTURE_DIR_NAME = 'reviewboard'
def test_review_request_published(self) -> None:
expected_topic = 'Scheduler'
expected_message = '**eeshangarg** opened [#2: Initial commit](https://rbcommons.com/s/zulip/r/2/):\n\n``` quote\n**Description**: Initial commit\n**Status**: pending\n**Target people**: **drsbgarg**\n**Branch**: master\n```'
self.send_and_test_stream_message(
'review_request_published',
expected_topic, expected_message,
HTTP_X_REVIEWBOARD_EVENT='review_request_published'
)
def test_review_request_published_with_multiple_target_people(self) -> None:
expected_topic = 'Scheduler'
expected_message = '**eeshangarg** opened [#2: Initial commit](https://rbcommons.com/s/zulip/r/2/):\n\n``` quote\n**Description**: Initial commit\n**Status**: pending\n**Target people**: **drsbgarg**, **johndoe**, and **janedoe**\n**Branch**: master\n```'
self.send_and_test_stream_message(
'review_request_published_with_multiple_target_people',
expected_topic, expected_message,
HTTP_X_REVIEWBOARD_EVENT='review_request_published'
)
def test_review_request_reopened(self) -> None:
expected_topic = 'Scheduler'
expected_message = '**eeshangarg** reopened [#1: Initial commit (first iteration)](https://rbcommons.com/s/zulip/r/1/):\n\n``` quote\n**Description**: Initial commit (first iteration)\n**Status**: pending\n**Target people**: **drsbgarg**\n**Branch**: master\n```'
self.send_and_test_stream_message(
'review_request_reopened',
expected_topic, expected_message,
HTTP_X_REVIEWBOARD_EVENT='review_request_reopened'
)
def test_review_request_closed(self) -> None:
expected_topic = 'Scheduler'
expected_message = '**eeshangarg** closed [#1: Initial commit (first iteration)](https://rbcommons.com/s/zulip/r/1/):\n\n``` quote\n**Description**: Initial commit (first iteration)\n**Status**: submitted\n**Target people**: **drsbgarg**\n**Close type**: submitted\n**Branch**: master\n```'
self.send_and_test_stream_message(
'review_request_closed',
expected_topic, expected_message,
HTTP_X_REVIEWBOARD_EVENT='review_request_closed'
)
def test_review_published(self) -> None:
expected_topic = 'Scheduler'
expected_message = '**eeshangarg** [reviewed](https://rbcommons.com/s/zulip/r/1/#review651728) [#1: Initial commit (first iteration)](https://rbcommons.com/s/zulip/r/1/):\n\n**Review**:\n``` quote\nLeft some minor comments, thanks!\n```'
self.send_and_test_stream_message(
'review_published',
expected_topic, expected_message,
HTTP_X_REVIEWBOARD_EVENT='review_published'
)
def test_reply_published(self) -> None:
expected_topic = 'Scheduler'
expected_message = '**drsbgarg** [replied](https://rbcommons.com/s/zulip/api/review-requests/1/reviews/651728/replies/651732/) to [#1: Initial commit (first iteration)](https://rbcommons.com/s/zulip/api/review-requests/1/):\n\n**Reply**:\n``` quote\n\n```'
self.send_and_test_stream_message(
'reply_published',
expected_topic, expected_message,
HTTP_X_REVIEWBOARD_EVENT='reply_published'
)

View File

@ -0,0 +1,180 @@
from typing import Any, Dict, Iterable, Optional
from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from zerver.decorator import api_key_only_webhook_view
from zerver.lib.webhooks.common import check_send_webhook_message, \
validate_extract_webhook_http_header, UnexpectedWebhookEventType
from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_error, json_success
from zerver.lib.validator import check_dict, check_string
from zerver.models import UserProfile
REVIEW_REQUEST_PUBLISHED = """
**{user_name}** opened [#{id}: {review_request_title}]({review_request_url}):
"""
REVIEW_REQUEST_REOPENED = """
**{user_name}** reopened [#{id}: {review_request_title}]({review_request_url}):
"""
REVIEW_REQUEST_CLOSED = """
**{user_name}** closed [#{id}: {review_request_title}]({review_request_url}):
"""
REVIEW_PUBLISHED = """
**{user_name}** [reviewed]({review_url}) [#{id}: {review_request_title}]({review_request_url}):
**Review**:
``` quote
{review_body_top}
```
"""
REVIEW_REQUEST_DETAILS = """
``` quote
**Description**: {description}
**Status**: {status}
**Target people**: {target_people}
{extra_info}
```
"""
REPLY_PUBLISHED = """
**{user_name}** [replied]({reply_url}) to [#{id}: {review_request_title}]({review_request_url}):
**Reply**:
``` quote
{reply_body_top}
```
"""
BRANCH_TEMPLATE = "**Branch**: {branch_name}"
def get_target_people_string(payload: Dict[str, Any]) -> str:
result = ""
target_people = payload['review_request']['target_people']
if len(target_people) == 1:
result = "**{title}**".format(**target_people[0])
else:
for target_person in target_people[:-1]:
result += "**{title}**, ".format(**target_person)
result += "and **{title}**".format(**target_people[-1])
return result
def get_review_published_body(payload: Dict[str, Any]) -> str:
kwargs = {
'review_url': payload['review']['absolute_url'],
'id': payload['review_request']['id'],
'review_request_title': payload['review_request']['summary'],
'review_request_url': payload['review_request']['absolute_url'],
'user_name': payload['review']['links']['user']['title'],
'review_body_top': payload['review']['body_top'],
}
return REVIEW_PUBLISHED.format(**kwargs).strip()
def get_reply_published_body(payload: Dict[str, Any]) -> str:
kwargs = {
'reply_url': payload['reply']['links']['self']['href'],
'id': payload['review_request']['id'],
'review_request_title': payload['review_request']['summary'],
'review_request_url': payload['review_request']['links']['self']['href'],
'user_name': payload['reply']['links']['user']['title'],
'user_url': payload['reply']['links']['user']['href'],
'reply_body_top': payload['reply']['body_top'],
}
return REPLY_PUBLISHED.format(**kwargs).strip()
def get_review_request_published_body(payload: Dict[str, Any]) -> str:
kwargs = {
'id': payload['review_request']['id'],
'review_request_title': payload['review_request']['summary'],
'review_request_url': payload['review_request']['absolute_url'],
'user_name': payload['review_request']['links']['submitter']['title'],
'description': payload['review_request']['description'],
'status': payload['review_request']['status'],
'target_people': get_target_people_string(payload),
'extra_info': '',
}
message = REVIEW_REQUEST_PUBLISHED + REVIEW_REQUEST_DETAILS
branch = payload['review_request'].get('branch')
if branch and branch is not None:
branch_info = BRANCH_TEMPLATE.format(branch_name=branch)
kwargs['extra_info'] = branch_info
return message.format(**kwargs).strip()
def get_review_request_reopened_body(payload: Dict[str, Any]) -> str:
kwargs = {
'id': payload['review_request']['id'],
'review_request_title': payload['review_request']['summary'],
'review_request_url': payload['review_request']['absolute_url'],
'user_name': payload['reopened_by']['username'],
'description': payload['review_request']['description'],
'status': payload['review_request']['status'],
'target_people': get_target_people_string(payload),
'extra_info': '',
}
message = REVIEW_REQUEST_REOPENED + REVIEW_REQUEST_DETAILS
branch = payload['review_request'].get('branch')
if branch and branch is not None:
branch_info = BRANCH_TEMPLATE.format(branch_name=branch)
kwargs['extra_info'] = branch_info
return message.format(**kwargs).strip()
def get_review_request_closed_body(payload: Dict[str, Any]) -> str:
kwargs = {
'id': payload['review_request']['id'],
'review_request_title': payload['review_request']['summary'],
'review_request_url': payload['review_request']['absolute_url'],
'user_name': payload['closed_by']['username'],
'description': payload['review_request']['description'],
'status': payload['review_request']['status'],
'target_people': get_target_people_string(payload),
'extra_info': '**Close type**: {}'.format(payload['close_type']),
}
message = REVIEW_REQUEST_CLOSED + REVIEW_REQUEST_DETAILS
branch = payload['review_request'].get('branch')
if branch and branch is not None:
branch_info = BRANCH_TEMPLATE.format(branch_name=branch)
kwargs['extra_info'] = '{}\n{}'.format(kwargs['extra_info'], branch_info)
return message.format(**kwargs).strip()
def get_review_request_repo_title(payload: Dict[str, Any]) -> str:
return payload['review_request']['links']['repository']['title']
RB_MESSAGE_FUNCTIONS = {
'review_request_published': get_review_request_published_body,
'review_request_reopened': get_review_request_reopened_body,
'review_request_closed': get_review_request_closed_body,
'review_published': get_review_published_body,
'reply_published': get_reply_published_body,
}
@api_key_only_webhook_view('ReviewBoard')
@has_request_variables
def api_reviewboard_webhook(
request: HttpRequest, user_profile: UserProfile,
payload: Dict[str, Iterable[Dict[str, Any]]]=REQ(argument_type='body')
) -> HttpResponse:
event_type = validate_extract_webhook_http_header(
request, 'X_REVIEWBOARD_EVENT', 'ReviewBoard')
body_function = RB_MESSAGE_FUNCTIONS.get(event_type)
if body_function is not None:
body = body_function(payload)
topic = get_review_request_repo_title(payload)
check_send_webhook_message(request, user_profile, topic, body)
else:
raise UnexpectedWebhookEventType('ReviewBoard', event_type)
return json_success()