diff --git a/zerver/webhooks/github/fixtures/pull_request__review_requested_team_reviewer.json b/zerver/webhooks/github/fixtures/pull_request__review_requested_team_reviewer.json new file mode 100644 index 0000000000..61181357ac --- /dev/null +++ b/zerver/webhooks/github/fixtures/pull_request__review_requested_team_reviewer.json @@ -0,0 +1,570 @@ +{ + "action": "review_requested", + "number": 4, + "pull_request": { + "url": "https://api.github.com/repos/test-org965/webhook-test/pulls/4", + "id": 384600887, + "node_id": "MDExOlB1bGxSZXF1ZXN0Mzg0NjAwODg3", + "html_url": "https://github.com/test-org965/webhook-test/pull/4", + "diff_url": "https://github.com/test-org965/webhook-test/pull/4.diff", + "patch_url": "https://github.com/test-org965/webhook-test/pull/4.patch", + "issue_url": "https://api.github.com/repos/test-org965/webhook-test/issues/4", + "number": 4, + "state": "open", + "locked": false, + "title": "testing webhook", + "user": { + "login": "singhsourabh", + "id": 32551625, + "node_id": "MDQ6VXNlcjMyNTUxNjI1", + "avatar_url": "https://avatars1.githubusercontent.com/u/32551625?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/singhsourabh", + "html_url": "https://github.com/singhsourabh", + "followers_url": "https://api.github.com/users/singhsourabh/followers", + "following_url": "https://api.github.com/users/singhsourabh/following{/other_user}", + "gists_url": "https://api.github.com/users/singhsourabh/gists{/gist_id}", + "starred_url": "https://api.github.com/users/singhsourabh/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/singhsourabh/subscriptions", + "organizations_url": "https://api.github.com/users/singhsourabh/orgs", + "repos_url": "https://api.github.com/users/singhsourabh/repos", + "events_url": "https://api.github.com/users/singhsourabh/events{/privacy}", + "received_events_url": "https://api.github.com/users/singhsourabh/received_events", + "type": "User", + "site_admin": false + }, + "body": "", + "created_at": "2020-03-06T02:22:43Z", + "updated_at": "2020-03-06T02:22:54Z", + "closed_at": null, + "merged_at": null, + "merge_commit_sha": "881d8a70d0291cf8a17295f1a4e7fc06d6b7667b", + "assignee": null, + "assignees": [], + "requested_reviewers": [ + { + "login": "shreyaskargit", + "id": 36965628, + "node_id": "MDQ6VXNlcjM2OTY1NjI4", + "avatar_url": "https://avatars3.githubusercontent.com/u/36965628?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/shreyaskargit", + "html_url": "https://github.com/shreyaskargit", + "followers_url": "https://api.github.com/users/shreyaskargit/followers", + "following_url": "https://api.github.com/users/shreyaskargit/following{/other_user}", + "gists_url": "https://api.github.com/users/shreyaskargit/gists{/gist_id}", + "starred_url": "https://api.github.com/users/shreyaskargit/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/shreyaskargit/subscriptions", + "organizations_url": "https://api.github.com/users/shreyaskargit/orgs", + "repos_url": "https://api.github.com/users/shreyaskargit/repos", + "events_url": "https://api.github.com/users/shreyaskargit/events{/privacy}", + "received_events_url": "https://api.github.com/users/shreyaskargit/received_events", + "type": "User", + "site_admin": false + }, + { + "login": "bajaj99prashant", + "id": 42171435, + "node_id": "MDQ6VXNlcjQyMTcxNDM1", + "avatar_url": "https://avatars2.githubusercontent.com/u/42171435?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/bajaj99prashant", + "html_url": "https://github.com/bajaj99prashant", + "followers_url": "https://api.github.com/users/bajaj99prashant/followers", + "following_url": "https://api.github.com/users/bajaj99prashant/following{/other_user}", + "gists_url": "https://api.github.com/users/bajaj99prashant/gists{/gist_id}", + "starred_url": "https://api.github.com/users/bajaj99prashant/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/bajaj99prashant/subscriptions", + "organizations_url": "https://api.github.com/users/bajaj99prashant/orgs", + "repos_url": "https://api.github.com/users/bajaj99prashant/repos", + "events_url": "https://api.github.com/users/bajaj99prashant/events{/privacy}", + "received_events_url": "https://api.github.com/users/bajaj99prashant/received_events", + "type": "User", + "site_admin": false + } + ], + "requested_teams": [ + { + "name": "review-team", + "id": 3692718, + "node_id": "MDQ6VGVhbTM2OTI3MTg=", + "slug": "review-team", + "description": "", + "privacy": "closed", + "url": "https://api.github.com/organizations/61805552/team/3692718", + "html_url": "https://github.com/orgs/test-org965/teams/review-team", + "members_url": "https://api.github.com/organizations/61805552/team/3692718/members{/member}", + "repositories_url": "https://api.github.com/organizations/61805552/team/3692718/repos", + "permission": "pull", + "parent": null + }, + { + "name": "authority", + "id": 3694601, + "node_id": "MDQ6VGVhbTM2OTQ2MDE=", + "slug": "authority", + "description": "", + "privacy": "closed", + "url": "https://api.github.com/organizations/61805552/team/3694601", + "html_url": "https://github.com/orgs/test-org965/teams/authority", + "members_url": "https://api.github.com/organizations/61805552/team/3694601/members{/member}", + "repositories_url": "https://api.github.com/organizations/61805552/team/3694601/repos", + "permission": "pull", + "parent": null + }, + { + "name": "management", + "id": 3694622, + "node_id": "MDQ6VGVhbTM2OTQ2MjI=", + "slug": "management", + "description": "", + "privacy": "closed", + "url": "https://api.github.com/organizations/61805552/team/3694622", + "html_url": "https://github.com/orgs/test-org965/teams/management", + "members_url": "https://api.github.com/organizations/61805552/team/3694622/members{/member}", + "repositories_url": "https://api.github.com/organizations/61805552/team/3694622/repos", + "permission": "pull", + "parent": { + "name": "authority", + "id": 3694601, + "node_id": "MDQ6VGVhbTM2OTQ2MDE=", + "slug": "authority", + "description": "", + "privacy": "closed", + "url": "https://api.github.com/organizations/61805552/team/3694601", + "html_url": "https://github.com/orgs/test-org965/teams/authority", + "members_url": "https://api.github.com/organizations/61805552/team/3694601/members{/member}", + "repositories_url": "https://api.github.com/organizations/61805552/team/3694601/repos", + "permission": "pull" + } + } + ], + "labels": [], + "milestone": null, + "commits_url": "https://api.github.com/repos/test-org965/webhook-test/pulls/4/commits", + "review_comments_url": "https://api.github.com/repos/test-org965/webhook-test/pulls/4/comments", + "review_comment_url": "https://api.github.com/repos/test-org965/webhook-test/pulls/comments{/number}", + "comments_url": "https://api.github.com/repos/test-org965/webhook-test/issues/4/comments", + "statuses_url": "https://api.github.com/repos/test-org965/webhook-test/statuses/08290f062a0fae68fc379cea22bc32ed1d518456", + "head": { + "label": "test-org965:dev", + "ref": "dev", + "sha": "08290f062a0fae68fc379cea22bc32ed1d518456", + "user": { + "login": "test-org965", + "id": 61805552, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjYxODA1NTUy", + "avatar_url": "https://avatars0.githubusercontent.com/u/61805552?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/test-org965", + "html_url": "https://github.com/test-org965", + "followers_url": "https://api.github.com/users/test-org965/followers", + "following_url": "https://api.github.com/users/test-org965/following{/other_user}", + "gists_url": "https://api.github.com/users/test-org965/gists{/gist_id}", + "starred_url": "https://api.github.com/users/test-org965/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/test-org965/subscriptions", + "organizations_url": "https://api.github.com/users/test-org965/orgs", + "repos_url": "https://api.github.com/users/test-org965/repos", + "events_url": "https://api.github.com/users/test-org965/events{/privacy}", + "received_events_url": "https://api.github.com/users/test-org965/received_events", + "type": "Organization", + "site_admin": false + }, + "repo": { + "id": 245057352, + "node_id": "MDEwOlJlcG9zaXRvcnkyNDUwNTczNTI=", + "name": "webhook-test", + "full_name": "test-org965/webhook-test", + "private": false, + "owner": { + "login": "test-org965", + "id": 61805552, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjYxODA1NTUy", + "avatar_url": "https://avatars0.githubusercontent.com/u/61805552?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/test-org965", + "html_url": "https://github.com/test-org965", + "followers_url": "https://api.github.com/users/test-org965/followers", + "following_url": "https://api.github.com/users/test-org965/following{/other_user}", + "gists_url": "https://api.github.com/users/test-org965/gists{/gist_id}", + "starred_url": "https://api.github.com/users/test-org965/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/test-org965/subscriptions", + "organizations_url": "https://api.github.com/users/test-org965/orgs", + "repos_url": "https://api.github.com/users/test-org965/repos", + "events_url": "https://api.github.com/users/test-org965/events{/privacy}", + "received_events_url": "https://api.github.com/users/test-org965/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/test-org965/webhook-test", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/test-org965/webhook-test", + "forks_url": "https://api.github.com/repos/test-org965/webhook-test/forks", + "keys_url": "https://api.github.com/repos/test-org965/webhook-test/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/test-org965/webhook-test/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/test-org965/webhook-test/teams", + "hooks_url": "https://api.github.com/repos/test-org965/webhook-test/hooks", + "issue_events_url": "https://api.github.com/repos/test-org965/webhook-test/issues/events{/number}", + "events_url": "https://api.github.com/repos/test-org965/webhook-test/events", + "assignees_url": "https://api.github.com/repos/test-org965/webhook-test/assignees{/user}", + "branches_url": "https://api.github.com/repos/test-org965/webhook-test/branches{/branch}", + "tags_url": "https://api.github.com/repos/test-org965/webhook-test/tags", + "blobs_url": "https://api.github.com/repos/test-org965/webhook-test/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/test-org965/webhook-test/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/test-org965/webhook-test/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/test-org965/webhook-test/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/test-org965/webhook-test/statuses/{sha}", + "languages_url": "https://api.github.com/repos/test-org965/webhook-test/languages", + "stargazers_url": "https://api.github.com/repos/test-org965/webhook-test/stargazers", + "contributors_url": "https://api.github.com/repos/test-org965/webhook-test/contributors", + "subscribers_url": "https://api.github.com/repos/test-org965/webhook-test/subscribers", + "subscription_url": "https://api.github.com/repos/test-org965/webhook-test/subscription", + "commits_url": "https://api.github.com/repos/test-org965/webhook-test/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/test-org965/webhook-test/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/test-org965/webhook-test/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/test-org965/webhook-test/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/test-org965/webhook-test/contents/{+path}", + "compare_url": "https://api.github.com/repos/test-org965/webhook-test/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/test-org965/webhook-test/merges", + "archive_url": "https://api.github.com/repos/test-org965/webhook-test/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/test-org965/webhook-test/downloads", + "issues_url": "https://api.github.com/repos/test-org965/webhook-test/issues{/number}", + "pulls_url": "https://api.github.com/repos/test-org965/webhook-test/pulls{/number}", + "milestones_url": "https://api.github.com/repos/test-org965/webhook-test/milestones{/number}", + "notifications_url": "https://api.github.com/repos/test-org965/webhook-test/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/test-org965/webhook-test/labels{/name}", + "releases_url": "https://api.github.com/repos/test-org965/webhook-test/releases{/id}", + "deployments_url": "https://api.github.com/repos/test-org965/webhook-test/deployments", + "created_at": "2020-03-05T03:12:28Z", + "updated_at": "2020-03-06T02:20:29Z", + "pushed_at": "2020-03-06T02:22:44Z", + "git_url": "git://github.com/test-org965/webhook-test.git", + "ssh_url": "git@github.com:test-org965/webhook-test.git", + "clone_url": "https://github.com/test-org965/webhook-test.git", + "svn_url": "https://github.com/test-org965/webhook-test", + "homepage": null, + "size": 1, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 1, + "license": null, + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "master" + } + }, + "base": { + "label": "test-org965:master", + "ref": "master", + "sha": "0813e6ef1b5a234b3b81d2c8f5a5bb3e4adf61a6", + "user": { + "login": "test-org965", + "id": 61805552, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjYxODA1NTUy", + "avatar_url": "https://avatars0.githubusercontent.com/u/61805552?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/test-org965", + "html_url": "https://github.com/test-org965", + "followers_url": "https://api.github.com/users/test-org965/followers", + "following_url": "https://api.github.com/users/test-org965/following{/other_user}", + "gists_url": "https://api.github.com/users/test-org965/gists{/gist_id}", + "starred_url": "https://api.github.com/users/test-org965/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/test-org965/subscriptions", + "organizations_url": "https://api.github.com/users/test-org965/orgs", + "repos_url": "https://api.github.com/users/test-org965/repos", + "events_url": "https://api.github.com/users/test-org965/events{/privacy}", + "received_events_url": "https://api.github.com/users/test-org965/received_events", + "type": "Organization", + "site_admin": false + }, + "repo": { + "id": 245057352, + "node_id": "MDEwOlJlcG9zaXRvcnkyNDUwNTczNTI=", + "name": "webhook-test", + "full_name": "test-org965/webhook-test", + "private": false, + "owner": { + "login": "test-org965", + "id": 61805552, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjYxODA1NTUy", + "avatar_url": "https://avatars0.githubusercontent.com/u/61805552?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/test-org965", + "html_url": "https://github.com/test-org965", + "followers_url": "https://api.github.com/users/test-org965/followers", + "following_url": "https://api.github.com/users/test-org965/following{/other_user}", + "gists_url": "https://api.github.com/users/test-org965/gists{/gist_id}", + "starred_url": "https://api.github.com/users/test-org965/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/test-org965/subscriptions", + "organizations_url": "https://api.github.com/users/test-org965/orgs", + "repos_url": "https://api.github.com/users/test-org965/repos", + "events_url": "https://api.github.com/users/test-org965/events{/privacy}", + "received_events_url": "https://api.github.com/users/test-org965/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/test-org965/webhook-test", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/test-org965/webhook-test", + "forks_url": "https://api.github.com/repos/test-org965/webhook-test/forks", + "keys_url": "https://api.github.com/repos/test-org965/webhook-test/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/test-org965/webhook-test/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/test-org965/webhook-test/teams", + "hooks_url": "https://api.github.com/repos/test-org965/webhook-test/hooks", + "issue_events_url": "https://api.github.com/repos/test-org965/webhook-test/issues/events{/number}", + "events_url": "https://api.github.com/repos/test-org965/webhook-test/events", + "assignees_url": "https://api.github.com/repos/test-org965/webhook-test/assignees{/user}", + "branches_url": "https://api.github.com/repos/test-org965/webhook-test/branches{/branch}", + "tags_url": "https://api.github.com/repos/test-org965/webhook-test/tags", + "blobs_url": "https://api.github.com/repos/test-org965/webhook-test/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/test-org965/webhook-test/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/test-org965/webhook-test/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/test-org965/webhook-test/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/test-org965/webhook-test/statuses/{sha}", + "languages_url": "https://api.github.com/repos/test-org965/webhook-test/languages", + "stargazers_url": "https://api.github.com/repos/test-org965/webhook-test/stargazers", + "contributors_url": "https://api.github.com/repos/test-org965/webhook-test/contributors", + "subscribers_url": "https://api.github.com/repos/test-org965/webhook-test/subscribers", + "subscription_url": "https://api.github.com/repos/test-org965/webhook-test/subscription", + "commits_url": "https://api.github.com/repos/test-org965/webhook-test/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/test-org965/webhook-test/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/test-org965/webhook-test/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/test-org965/webhook-test/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/test-org965/webhook-test/contents/{+path}", + "compare_url": "https://api.github.com/repos/test-org965/webhook-test/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/test-org965/webhook-test/merges", + "archive_url": "https://api.github.com/repos/test-org965/webhook-test/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/test-org965/webhook-test/downloads", + "issues_url": "https://api.github.com/repos/test-org965/webhook-test/issues{/number}", + "pulls_url": "https://api.github.com/repos/test-org965/webhook-test/pulls{/number}", + "milestones_url": "https://api.github.com/repos/test-org965/webhook-test/milestones{/number}", + "notifications_url": "https://api.github.com/repos/test-org965/webhook-test/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/test-org965/webhook-test/labels{/name}", + "releases_url": "https://api.github.com/repos/test-org965/webhook-test/releases{/id}", + "deployments_url": "https://api.github.com/repos/test-org965/webhook-test/deployments", + "created_at": "2020-03-05T03:12:28Z", + "updated_at": "2020-03-06T02:20:29Z", + "pushed_at": "2020-03-06T02:22:44Z", + "git_url": "git://github.com/test-org965/webhook-test.git", + "ssh_url": "git@github.com:test-org965/webhook-test.git", + "clone_url": "https://github.com/test-org965/webhook-test.git", + "svn_url": "https://github.com/test-org965/webhook-test", + "homepage": null, + "size": 1, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 1, + "license": null, + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "master" + } + }, + "_links": { + "self": { + "href": "https://api.github.com/repos/test-org965/webhook-test/pulls/4" + }, + "html": { + "href": "https://github.com/test-org965/webhook-test/pull/4" + }, + "issue": { + "href": "https://api.github.com/repos/test-org965/webhook-test/issues/4" + }, + "comments": { + "href": "https://api.github.com/repos/test-org965/webhook-test/issues/4/comments" + }, + "review_comments": { + "href": "https://api.github.com/repos/test-org965/webhook-test/pulls/4/comments" + }, + "review_comment": { + "href": "https://api.github.com/repos/test-org965/webhook-test/pulls/comments{/number}" + }, + "commits": { + "href": "https://api.github.com/repos/test-org965/webhook-test/pulls/4/commits" + }, + "statuses": { + "href": "https://api.github.com/repos/test-org965/webhook-test/statuses/08290f062a0fae68fc379cea22bc32ed1d518456" + } + }, + "author_association": "CONTRIBUTOR", + "draft": false, + "merged": false, + "mergeable": true, + "rebaseable": true, + "mergeable_state": "clean", + "merged_by": null, + "comments": 0, + "review_comments": 0, + "maintainer_can_modify": false, + "commits": 1, + "additions": 1, + "deletions": 1, + "changed_files": 1 + }, + "requested_team": { + "name": "authority", + "id": 3694601, + "node_id": "MDQ6VGVhbTM2OTQ2MDE=", + "slug": "authority", + "description": "", + "privacy": "closed", + "url": "https://api.github.com/organizations/61805552/team/3694601", + "html_url": "https://github.com/orgs/test-org965/teams/authority", + "members_url": "https://api.github.com/organizations/61805552/team/3694601/members{/member}", + "repositories_url": "https://api.github.com/organizations/61805552/team/3694601/repos", + "permission": "pull", + "parent": null + }, + "repository": { + "id": 245057352, + "node_id": "MDEwOlJlcG9zaXRvcnkyNDUwNTczNTI=", + "name": "webhook-test", + "full_name": "test-org965/webhook-test", + "private": false, + "owner": { + "login": "test-org965", + "id": 61805552, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjYxODA1NTUy", + "avatar_url": "https://avatars0.githubusercontent.com/u/61805552?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/test-org965", + "html_url": "https://github.com/test-org965", + "followers_url": "https://api.github.com/users/test-org965/followers", + "following_url": "https://api.github.com/users/test-org965/following{/other_user}", + "gists_url": "https://api.github.com/users/test-org965/gists{/gist_id}", + "starred_url": "https://api.github.com/users/test-org965/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/test-org965/subscriptions", + "organizations_url": "https://api.github.com/users/test-org965/orgs", + "repos_url": "https://api.github.com/users/test-org965/repos", + "events_url": "https://api.github.com/users/test-org965/events{/privacy}", + "received_events_url": "https://api.github.com/users/test-org965/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/test-org965/webhook-test", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/test-org965/webhook-test", + "forks_url": "https://api.github.com/repos/test-org965/webhook-test/forks", + "keys_url": "https://api.github.com/repos/test-org965/webhook-test/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/test-org965/webhook-test/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/test-org965/webhook-test/teams", + "hooks_url": "https://api.github.com/repos/test-org965/webhook-test/hooks", + "issue_events_url": "https://api.github.com/repos/test-org965/webhook-test/issues/events{/number}", + "events_url": "https://api.github.com/repos/test-org965/webhook-test/events", + "assignees_url": "https://api.github.com/repos/test-org965/webhook-test/assignees{/user}", + "branches_url": "https://api.github.com/repos/test-org965/webhook-test/branches{/branch}", + "tags_url": "https://api.github.com/repos/test-org965/webhook-test/tags", + "blobs_url": "https://api.github.com/repos/test-org965/webhook-test/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/test-org965/webhook-test/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/test-org965/webhook-test/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/test-org965/webhook-test/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/test-org965/webhook-test/statuses/{sha}", + "languages_url": "https://api.github.com/repos/test-org965/webhook-test/languages", + "stargazers_url": "https://api.github.com/repos/test-org965/webhook-test/stargazers", + "contributors_url": "https://api.github.com/repos/test-org965/webhook-test/contributors", + "subscribers_url": "https://api.github.com/repos/test-org965/webhook-test/subscribers", + "subscription_url": "https://api.github.com/repos/test-org965/webhook-test/subscription", + "commits_url": "https://api.github.com/repos/test-org965/webhook-test/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/test-org965/webhook-test/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/test-org965/webhook-test/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/test-org965/webhook-test/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/test-org965/webhook-test/contents/{+path}", + "compare_url": "https://api.github.com/repos/test-org965/webhook-test/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/test-org965/webhook-test/merges", + "archive_url": "https://api.github.com/repos/test-org965/webhook-test/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/test-org965/webhook-test/downloads", + "issues_url": "https://api.github.com/repos/test-org965/webhook-test/issues{/number}", + "pulls_url": "https://api.github.com/repos/test-org965/webhook-test/pulls{/number}", + "milestones_url": "https://api.github.com/repos/test-org965/webhook-test/milestones{/number}", + "notifications_url": "https://api.github.com/repos/test-org965/webhook-test/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/test-org965/webhook-test/labels{/name}", + "releases_url": "https://api.github.com/repos/test-org965/webhook-test/releases{/id}", + "deployments_url": "https://api.github.com/repos/test-org965/webhook-test/deployments", + "created_at": "2020-03-05T03:12:28Z", + "updated_at": "2020-03-06T02:20:29Z", + "pushed_at": "2020-03-06T02:22:44Z", + "git_url": "git://github.com/test-org965/webhook-test.git", + "ssh_url": "git@github.com:test-org965/webhook-test.git", + "clone_url": "https://github.com/test-org965/webhook-test.git", + "svn_url": "https://github.com/test-org965/webhook-test", + "homepage": null, + "size": 1, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 1, + "license": null, + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "master" + }, + "organization": { + "login": "test-org965", + "id": 61805552, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjYxODA1NTUy", + "url": "https://api.github.com/orgs/test-org965", + "repos_url": "https://api.github.com/orgs/test-org965/repos", + "events_url": "https://api.github.com/orgs/test-org965/events", + "hooks_url": "https://api.github.com/orgs/test-org965/hooks", + "issues_url": "https://api.github.com/orgs/test-org965/issues", + "members_url": "https://api.github.com/orgs/test-org965/members{/member}", + "public_members_url": "https://api.github.com/orgs/test-org965/public_members{/member}", + "avatar_url": "https://avatars0.githubusercontent.com/u/61805552?v=4", + "description": null + }, + "sender": { + "login": "singhsourabh", + "id": 32551625, + "node_id": "MDQ6VXNlcjMyNTUxNjI1", + "avatar_url": "https://avatars1.githubusercontent.com/u/32551625?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/singhsourabh", + "html_url": "https://github.com/singhsourabh", + "followers_url": "https://api.github.com/users/singhsourabh/followers", + "following_url": "https://api.github.com/users/singhsourabh/following{/other_user}", + "gists_url": "https://api.github.com/users/singhsourabh/gists{/gist_id}", + "starred_url": "https://api.github.com/users/singhsourabh/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/singhsourabh/subscriptions", + "organizations_url": "https://api.github.com/users/singhsourabh/orgs", + "repos_url": "https://api.github.com/users/singhsourabh/repos", + "events_url": "https://api.github.com/users/singhsourabh/events{/privacy}", + "received_events_url": "https://api.github.com/users/singhsourabh/received_events", + "type": "User", + "site_admin": false + } +} diff --git a/zerver/webhooks/github/tests.py b/zerver/webhooks/github/tests.py index 023f7ddc30..9055906164 100644 --- a/zerver/webhooks/github/tests.py +++ b/zerver/webhooks/github/tests.py @@ -274,11 +274,17 @@ class GithubWebhookTest(WebhookTestCase): expected_message) def test_pull_request_review_requested_multiple_reviwers_msg(self) -> None: - expected_message = u"**eeshangarg** requested [showell](https://github.com/showell), and [timabbott](https://github.com/timabbott) for a review on [PR #1](https://github.com/eeshangarg/Scheduler/pull/1)." + expected_message = u"**eeshangarg** requested [showell](https://github.com/showell) and [timabbott](https://github.com/timabbott) for a review on [PR #1](https://github.com/eeshangarg/Scheduler/pull/1)." self.send_and_test_stream_message('pull_request__review_requested_multiple_reviewers', 'Scheduler / PR #1 This is just a test commit', expected_message) + def test_pull_request__review_requested_team_reviewer_msg(self) -> None: + expected_message = u"**singhsourabh** requested [shreyaskargit](https://github.com/shreyaskargit), [bajaj99prashant](https://github.com/bajaj99prashant), [review-team](https://github.com/orgs/test-org965/teams/review-team), [authority](https://github.com/orgs/test-org965/teams/authority) and [management](https://github.com/orgs/test-org965/teams/management) for a review on [PR #4](https://github.com/test-org965/webhook-test/pull/4)." + self.send_and_test_stream_message('pull_request__review_requested_team_reviewer', + 'webhook-test / PR #4 testing webhook', + expected_message) + def test_pull_request_review_requested_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic='notifications') expected_topic = u"notifications" diff --git a/zerver/webhooks/github/view.py b/zerver/webhooks/github/view.py index f161809f7a..19d309a837 100644 --- a/zerver/webhooks/github/view.py +++ b/zerver/webhooks/github/view.py @@ -313,8 +313,12 @@ def get_pull_request_review_comment_body(payload: Dict[str, Any], def get_pull_request_review_requested_body(payload: Dict[str, Any], include_title: Optional[bool]=False) -> str: - requested_reviewers = (payload['pull_request']['requested_reviewers'] or - [payload['requested_reviewer']]) + requested_reviewer = [payload['requested_reviewer']] if 'requested_reviewer' in payload else [] + requested_reviewers = (payload['pull_request']['requested_reviewers'] or requested_reviewer) + + requested_team = [payload['requested_team']] if 'requested_team' in payload else [] + requested_team_reviewers = (payload['pull_request']['requested_teams'] or requested_team) + sender = get_sender_name(payload) pr_number = payload['pull_request']['number'] pr_url = payload['pull_request']['html_url'] @@ -323,13 +327,19 @@ def get_pull_request_review_requested_body(payload: Dict[str, Any], "[PR #{pr_number} {title}]({pr_url}).") body = message_with_title if include_title else message + all_reviewers = [] + + for reviewer in requested_reviewers: + all_reviewers.append("[{login}]({html_url})".format(**reviewer)) + + for team_reviewer in requested_team_reviewers: + all_reviewers.append("[{name}]({html_url})".format(**team_reviewer)) + reviewers = "" - if len(requested_reviewers) == 1: - reviewers = "[{login}]({html_url})".format(**requested_reviewers[0]) + if len(all_reviewers) == 1: + reviewers = all_reviewers[0] else: - for reviewer in requested_reviewers[:-1]: - reviewers += "[{login}]({html_url}), ".format(**reviewer) - reviewers += "and [{login}]({html_url})".format(**requested_reviewers[-1]) + reviewers = "{} and {}".format(', '.join(all_reviewers[:-1]), all_reviewers[-1]) return body.format( sender=sender,