Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
Revert "Delete the Bitbucket Server integration." and rebrand.
Niloth P131078ba354d
diff --git a/static/images/integrations/bitbucketdatacenter/001.png b/static/images/integrations/bitbucketdatacenter/001.pngnew file mode 100644index 00000000000..79a7ce247a5Binary files /dev/null and b/static/images/integrations/bitbucketdatacenter/001.png differdiff --git a/zerver/lib/integrations.py b/zerver/lib/integrations.pyindex 35c715d6e1f..d6e24f30cc7 100644--- a/zerver/lib/integrations.py+++ b/zerver/lib/integrations.py@@ -557,6 +557,21 @@ INCOMING_WEBHOOK_INTEGRATIONS: list[IncomingWebhookIntegration] = [url_options=[WebhookUrlOption.build_preset_config(PresetUrlOption.BRANCHES)],legacy_names=["bitbucket2"],),+ IncomingWebhookIntegration(+ "bitbucketdatacenter",+ ["version-control"],+ [+ WebhookScreenshotConfig(+ "repo_push_update_single_branch.json",+ bot_name="Bitbucket Data Center Bot",+ channel="commits",+ )+ ],+ logo="images/integrations/logos/bitbucket.svg",+ display_name="Bitbucket Data Center",+ url_options=[WebhookUrlOption.build_preset_config(PresetUrlOption.BRANCHES)],+ legacy_names=["bitbucket3"],+ ),IncomingWebhookIntegration("buildbot", ["continuous-integration"], [WebhookScreenshotConfig("started.json")]),diff --git a/zerver/lib/webhooks/git.py b/zerver/lib/webhooks/git.pyindex 317f74db899..d7908025125 100644--- a/zerver/lib/webhooks/git.py+++ b/zerver/lib/webhooks/git.py@@ -46,6 +46,7 @@ FORCE_PUSH_COMMITS_MESSAGE_TEMPLATE = ("{user_name} [force pushed]({url}) to branch {branch_name}. Head is now {head}.")CREATE_BRANCH_MESSAGE_TEMPLATE = "{user_name} created [{branch_name}]({url}) branch."+CREATE_BRANCH_WITHOUT_URL_MESSAGE_TEMPLATE = "{user_name} created {branch_name} branch."REMOVE_BRANCH_MESSAGE_TEMPLATE = "{user_name} deleted branch {branch_name}."ISSUE_LABELED_OR_UNLABELED_MESSAGE_TEMPLATE = (@@ -59,6 +60,7 @@ ISSUE_MILESTONED_OR_DEMILESTONED_MESSAGE_TEMPLATE_WITH_TITLE = "[{user_name}]({uPULL_REQUEST_OR_ISSUE_MESSAGE_TEMPLATE = "{user_name} {action}{assignee} [{type}{id}{title}]({url})"PULL_REQUEST_OR_ISSUE_MESSAGE_TEMPLATE_WITHOUT_REFERENCE = "{user_name} {action}"PULL_REQUEST_OR_ISSUE_ASSIGNEE_INFO_TEMPLATE = "(assigned to {assignee})"+PULL_REQUEST_REVIEWER_INFO_TEMPLATE = "(assigned reviewers: {reviewer})"PULL_REQUEST_BRANCH_INFO_TEMPLATE = "from `{target}` to `{base}`"CONTENT_MESSAGE_TEMPLATE = "\n{fence} quote\n{message}\n{fence}"@@ -180,6 +182,11 @@ def get_force_push_commits_event_message(def get_create_branch_event_message(user_name: str, url: str | None, branch_name: str) -> str:+ if url is None:+ return CREATE_BRANCH_WITHOUT_URL_MESSAGE_TEMPLATE.format(+ user_name=user_name,+ branch_name=branch_name,+ )return CREATE_BRANCH_MESSAGE_TEMPLATE.format(user_name=user_name,url=url,@@ -206,6 +213,7 @@ def get_pull_request_event_message(assignee: str | None = None,assignees: list[dict[str, Any]] | None = None,assignee_updated: str | None = None,+ reviewer: str | None = None,type: str = "PR",title: str | None = None,suffix: str | None = None,@@ -257,7 +265,10 @@ def get_pull_request_event_message(elif assignee:assignee_info = PULL_REQUEST_OR_ISSUE_ASSIGNEE_INFO_TEMPLATE.format(assignee=assignee)- if assignees or assignee:+ elif reviewer:+ assignee_info = PULL_REQUEST_REVIEWER_INFO_TEMPLATE.format(reviewer=reviewer)++ if assignees or assignee or reviewer:main_message = f"{main_message} {assignee_info}"if suffix:diff --git a/zerver/webhooks/bitbucketdatacenter/__init__.py b/zerver/webhooks/bitbucketdatacenter/__init__.pynew file mode 100644index 00000000000..e69de29bb2ddiff --git a/zerver/webhooks/bitbucketdatacenter/doc.md b/zerver/webhooks/bitbucketdatacenter/doc.mdnew file mode 100644index 00000000000..35066930657--- /dev/null+++ b/zerver/webhooks/bitbucketdatacenter/doc.md@@ -0,0 +1,33 @@+# Zulip Bitbucket Data Center integration++Zulip supports both Git and Mercurial notifications from Bitbucket. This+integration is for the webhooks used by Bitbucket Data Center.++For the new-style webhooks used by Bitbucket Cloud (SAAS service) click+[here](./bitbucket).++{start_tabs}++1. {!create-an-incoming-webhook.md!}++1. {!generate-webhook-url-with-branch-filtering.md!}++1. On your repository's web page, go to **Settings**. Select+ **Webhooks**, and then click **Add webhook**.++1. Set **Title** to a title of your choice, such as `Zulip`. Set **URL**+ to the URL generated above, and toggle the **Active** checkbox.+ Select the **Triggers** you'd like to be notified about, and click+ **Save**.++{end_tabs}++{!congrats.md!}++++{!event-filtering-additional-feature.md!}++### Related documentation++{!webhooks-url-specification.md!}diff --git a/zerver/webhooks/bitbucketdatacenter/fixtures/commit_comment_added.json b/zerver/webhooks/bitbucketdatacenter/fixtures/commit_comment_added.jsonnew file mode 100644index 00000000000..177a64b723b--- /dev/null+++ b/zerver/webhooks/bitbucketdatacenter/fixtures/commit_comment_added.json@@ -0,0 +1,90 @@+{+ "actor": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "comment": {+ "author": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "id": 1,+ "updatedDate": 1553169751306,+ "tasks": [],+ "comments": [],+ "version": 0,+ "text": "Just an arbitrary comment on a commit.",+ "createdDate": 1553169751306,+ "properties": {+ "repositoryId": 2+ }+ },+ "commit": "508d1b67f1f8f3a25f543a030a7a178894aa9907",+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "eventKey": "repo:comment:added",+ "date": "2019-03-21T17:32:31+0530"+}diff --git a/zerver/webhooks/bitbucketdatacenter/fixtures/commit_comment_deleted.json b/zerver/webhooks/bitbucketdatacenter/fixtures/commit_comment_deleted.jsonnew file mode 100644index 00000000000..9cfe8bbc90f--- /dev/null+++ b/zerver/webhooks/bitbucketdatacenter/fixtures/commit_comment_deleted.json@@ -0,0 +1,87 @@+{+ "actor": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "comment": {+ "author": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "id": 1,+ "updatedDate": 1553169856827,+ "tasks": [],+ "comments": [],+ "version": 1,+ "text": "Just an arbitrary comment on a commit. Nothing to see here...",+ "createdDate": 1553169751306+ },+ "commit": "508d1b67f1f8f3a25f543a030a7a178894aa9907",+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "eventKey": "repo:comment:deleted",+ "date": "2019-03-21T17:34:57+0530"+}diff --git a/zerver/webhooks/bitbucketdatacenter/fixtures/commit_comment_edited.json b/zerver/webhooks/bitbucketdatacenter/fixtures/commit_comment_edited.jsonnew file mode 100644index 00000000000..b4e3fdd5ff2--- /dev/null+++ b/zerver/webhooks/bitbucketdatacenter/fixtures/commit_comment_edited.json@@ -0,0 +1,91 @@+{+ "actor": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "comment": {+ "author": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "id": 1,+ "updatedDate": 1553169856827,+ "tasks": [],+ "comments": [],+ "version": 1,+ "text": "Just an arbitrary comment on a commit. Nothing to see here...",+ "createdDate": 1553169751306,+ "properties": {+ "repositoryId": 2+ }+ },+ "previousComment": "Just an arbitrary comment on a commit.",+ "commit": "508d1b67f1f8f3a25f543a030a7a178894aa9907",+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "eventKey": "repo:comment:edited",+ "date": "2019-03-21T17:34:16+0530"+}diff --git a/zerver/webhooks/bitbucketdatacenter/fixtures/diagnostics_ping.json b/zerver/webhooks/bitbucketdatacenter/fixtures/diagnostics_ping.jsonnew file mode 100644index 00000000000..7ae9fec5c29--- /dev/null+++ b/zerver/webhooks/bitbucketdatacenter/fixtures/diagnostics_ping.json@@ -0,0 +1,3 @@+{+ "test": true+}diff --git a/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_add_reviewer.json b/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_add_reviewer.jsonnew file mode 100644index 00000000000..05a9b681f12--- /dev/null+++ b/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_add_reviewer.json@@ -0,0 +1,251 @@+{+ "addedReviewers": [+ {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/shimura"+ }+ ]+ },+ "displayName": "Shimura Shinpachi",+ "emailAddress": "[email protected]",+ "slug": "shimura",+ "id": 2,+ "name": "shimura"+ }+ ],+ "actor": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "pullRequest": {+ "locked": false,+ "state": "OPEN",+ "description": "* Add file2.txt\n* Add file3.txt\nBoth of these files would be important additions to the project!",+ "closed": false,+ "open": true,+ "title": "Branch1",+ "toRef": {+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "id": "refs/heads/master",+ "displayId": "master",+ "latestCommit": "508d1b67f1f8f3a25f543a030a7a178894aa9907"+ },+ "reviewers": [+ {+ "status": "UNAPPROVED",+ "role": "REVIEWER",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/shimura"+ }+ ]+ },+ "displayName": "Shimura Shinpachi",+ "emailAddress": "[email protected]",+ "slug": "shimura",+ "id": 2,+ "name": "shimura"+ },+ "approved": false+ }+ ],+ "author": {+ "status": "UNAPPROVED",+ "role": "AUTHOR",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "approved": false+ },+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/1"+ }+ ]+ },+ "createdDate": 1553172738844,+ "fromRef": {+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/~hypro999/sandbox-fork.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/~hypro999/sandbox-fork.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999/repos/sandbox-fork/browse"+ }+ ]+ },+ "forkable": true,+ "origin": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "slug": "sandbox-fork",+ "project": {+ "key": "~HYPRO999",+ "type": "PERSONAL",+ "owner": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "id": 3,+ "name": "Hemanth V. Alluri"+ },+ "id": 4,+ "scmId": "git",+ "public": false,+ "name": "sandbox fork",+ "statusMessage": "Available"+ },+ "id": "refs/heads/branch1",+ "displayId": "branch1",+ "latestCommit": "3980c2be32a7e23c795741d5dc1a2eecb9b85d6d"+ },+ "version": 1,+ "id": 1,+ "updatedDate": 1553337991505,+ "participants": []+ },+ "removedReviewers": [],+ "eventKey": "pr:reviewer:updated",+ "date": "2019-03-23T16:16:31+0530"+}diff --git a/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_add_two_reviewers.json b/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_add_two_reviewers.jsonnew file mode 100644index 00000000000..84ba158f5f2--- /dev/null+++ b/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_add_two_reviewers.json@@ -0,0 +1,288 @@+{+ "addedReviewers": [+ {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/shimura"+ }+ ]+ },+ "displayName": "Shimura Shinpachi",+ "emailAddress": "[email protected]",+ "slug": "shimura",+ "id": 2,+ "name": "shimura"+ },+ {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/sougo"+ }+ ]+ },+ "displayName": "Okita Sougo",+ "emailAddress": "[email protected]",+ "slug": "sougo",+ "id": 3,+ "name": "sougo"+ }+ ],+ "actor": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "pullRequest": {+ "locked": false,+ "state": "OPEN",+ "description": "* Add file2.txt\n* Add file3.txt\nBoth of these files would be important additions to the project!",+ "closed": false,+ "open": true,+ "title": "Branch1",+ "toRef": {+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "id": "refs/heads/master",+ "displayId": "master",+ "latestCommit": "508d1b67f1f8f3a25f543a030a7a178894aa9907"+ },+ "reviewers": [+ {+ "status": "UNAPPROVED",+ "role": "REVIEWER",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/shimura"+ }+ ]+ },+ "displayName": "Shimura Shinpachi",+ "emailAddress": "[email protected]",+ "slug": "shimura",+ "id": 2,+ "name": "shimura"+ },+ "approved": false+ },+ {+ "status": "UNAPPROVED",+ "role": "REVIEWER",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/sougo"+ }+ ]+ },+ "displayName": "Okita Sougo",+ "emailAddress": "[email protected]",+ "slug": "sougo",+ "id": 3,+ "name": "sougo"+ },+ "approved": false+ }+ ],+ "author": {+ "status": "UNAPPROVED",+ "role": "AUTHOR",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "approved": false+ },+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/1"+ }+ ]+ },+ "createdDate": 1553172738844,+ "fromRef": {+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/~hypro999/sandbox-fork.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/~hypro999/sandbox-fork.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999/repos/sandbox-fork/browse"+ }+ ]+ },+ "forkable": true,+ "origin": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "slug": "sandbox-fork",+ "project": {+ "key": "~HYPRO999",+ "type": "PERSONAL",+ "owner": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "id": 3,+ "name": "Hemanth V. Alluri"+ },+ "id": 4,+ "scmId": "git",+ "public": false,+ "name": "sandbox fork",+ "statusMessage": "Available"+ },+ "id": "refs/heads/branch1",+ "displayId": "branch1",+ "latestCommit": "91c9c6998c9768ca678048ddee7f9e480e6d54de"+ },+ "version": 4,+ "id": 1,+ "updatedDate": 1553344009793,+ "participants": []+ },+ "removedReviewers": [],+ "eventKey": "pr:reviewer:updated",+ "date": "2019-03-23T17:56:50+0530"+}diff --git a/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_approved.json b/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_approved.jsonnew file mode 100644index 00000000000..0774280d63f--- /dev/null+++ b/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_approved.json@@ -0,0 +1,298 @@+{+ "actor": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/zura"+ }+ ]+ },+ "displayName": "Katsura Kotarou",+ "emailAddress": "[email protected]",+ "slug": "zura",+ "id": 4,+ "name": "zura"+ },+ "previousStatus": "UNAPPROVED",+ "participant": {+ "status": "APPROVED",+ "role": "REVIEWER",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/zura"+ }+ ]+ },+ "displayName": "Katsura Kotarou",+ "emailAddress": "[email protected]",+ "slug": "zura",+ "id": 4,+ "name": "zura"+ },+ "lastReviewedCommit": "556bde1a2442562568fce6016de570516ac1c4f6",+ "approved": true+ },+ "pullRequest": {+ "locked": false,+ "state": "OPEN",+ "description": "Add a simple text file for further testing purposes.",+ "closed": false,+ "open": true,+ "title": "sample_file: Add sample_file.txt.",+ "toRef": {+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "id": "refs/heads/master",+ "displayId": "master",+ "latestCommit": "d46b4d2e3326e106147c0ea748f7defba29d9e1e"+ },+ "reviewers": [+ {+ "status": "APPROVED",+ "role": "REVIEWER",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/zura"+ }+ ]+ },+ "displayName": "Katsura Kotarou",+ "emailAddress": "[email protected]",+ "slug": "zura",+ "id": 4,+ "name": "zura"+ },+ "lastReviewedCommit": "556bde1a2442562568fce6016de570516ac1c4f6",+ "approved": true+ },+ {+ "status": "UNAPPROVED",+ "role": "REVIEWER",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/sougo"+ }+ ]+ },+ "displayName": "Okita Sougo",+ "emailAddress": "[email protected]",+ "slug": "sougo",+ "id": 3,+ "name": "sougo"+ },+ "approved": false+ },+ {+ "status": "UNAPPROVED",+ "role": "REVIEWER",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/shimura"+ }+ ]+ },+ "displayName": "Shimura Shinpachi",+ "emailAddress": "[email protected]",+ "slug": "shimura",+ "id": 2,+ "name": "shimura"+ },+ "approved": false+ }+ ],+ "author": {+ "status": "UNAPPROVED",+ "role": "AUTHOR",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "approved": false+ },+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/6"+ }+ ]+ },+ "createdDate": 1553572666612,+ "fromRef": {+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/~hypro999/sandbox-fork.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/~hypro999/sandbox-fork.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999/repos/sandbox-fork/browse"+ }+ ]+ },+ "forkable": true,+ "origin": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "slug": "sandbox-fork",+ "project": {+ "key": "~HYPRO999",+ "type": "PERSONAL",+ "owner": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "id": 3,+ "name": "Hemanth V. Alluri"+ },+ "id": 4,+ "scmId": "git",+ "public": false,+ "name": "sandbox fork",+ "statusMessage": "Available"+ },+ "id": "refs/heads/master",+ "displayId": "master",+ "latestCommit": "556bde1a2442562568fce6016de570516ac1c4f6"+ },+ "version": 0,+ "id": 6,+ "updatedDate": 1553572666612,+ "participants": []+ },+ "eventKey": "pr:reviewer:approved",+ "date": "2019-03-26T15:47:11+0530"+}diff --git a/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_comment_added.json b/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_comment_added.jsonnew file mode 100644index 00000000000..caead4ff02a--- /dev/null+++ b/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_comment_added.json@@ -0,0 +1,302 @@+{+ "comment": {+ "author": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/zura"+ }+ ]+ },+ "displayName": "Katsura Kotarou",+ "emailAddress": "[email protected]",+ "slug": "zura",+ "id": 4,+ "name": "zura"+ },+ "id": 2,+ "updatedDate": 1553585547535,+ "tasks": [],+ "comments": [],+ "version": 0,+ "text": "This seems like a pretty good idea.",+ "createdDate": 1553585547535,+ "properties": {+ "repositoryId": 2+ }+ },+ "actor": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/zura"+ }+ ]+ },+ "displayName": "Katsura Kotarou",+ "emailAddress": "[email protected]",+ "slug": "zura",+ "id": 4,+ "name": "zura"+ },+ "eventKey": "pr:comment:added",+ "date": "2019-03-26T13:02:27+0530",+ "pullRequest": {+ "locked": false,+ "state": "OPEN",+ "description": "Add a simple text file for further testing purposes.",+ "closed": false,+ "open": true,+ "title": "sample_file: Add sample_file.txt.",+ "toRef": {+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "id": "refs/heads/master",+ "displayId": "master",+ "latestCommit": "d46b4d2e3326e106147c0ea748f7defba29d9e1e"+ },+ "reviewers": [+ {+ "status": "UNAPPROVED",+ "role": "REVIEWER",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/sougo"+ }+ ]+ },+ "displayName": "Okita Sougo",+ "emailAddress": "[email protected]",+ "slug": "sougo",+ "id": 3,+ "name": "sougo"+ },+ "approved": false+ },+ {+ "status": "UNAPPROVED",+ "role": "REVIEWER",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/shimura"+ }+ ]+ },+ "displayName": "Shimura Shinpachi",+ "emailAddress": "[email protected]",+ "slug": "shimura",+ "id": 2,+ "name": "shimura"+ },+ "approved": false+ },+ {+ "status": "UNAPPROVED",+ "role": "REVIEWER",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/zura"+ }+ ]+ },+ "displayName": "Katsura Kotarou",+ "emailAddress": "[email protected]",+ "slug": "zura",+ "id": 4,+ "name": "zura"+ },+ "approved": false+ }+ ],+ "author": {+ "status": "UNAPPROVED",+ "role": "AUTHOR",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "approved": false+ },+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/6"+ }+ ]+ },+ "createdDate": 1553572666612,+ "fromRef": {+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/~hypro999/sandbox-fork.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/~hypro999/sandbox-fork.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999/repos/sandbox-fork/browse"+ }+ ]+ },+ "forkable": true,+ "origin": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "slug": "sandbox-fork",+ "project": {+ "key": "~HYPRO999",+ "type": "PERSONAL",+ "owner": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "id": 3,+ "name": "Hemanth V. Alluri"+ },+ "id": 4,+ "scmId": "git",+ "public": false,+ "name": "sandbox fork",+ "statusMessage": "Available"+ },+ "id": "refs/heads/master",+ "displayId": "master",+ "latestCommit": "556bde1a2442562568fce6016de570516ac1c4f6"+ },+ "version": 0,+ "id": 6,+ "updatedDate": 1553572666612,+ "participants": []+ }+}diff --git a/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_comment_deleted.json b/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_comment_deleted.jsonnew file mode 100644index 00000000000..cf7f16d24aa--- /dev/null+++ b/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_comment_deleted.json@@ -0,0 +1,299 @@+{+ "comment": {+ "author": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/zura"+ }+ ]+ },+ "displayName": "Katsura Kotarou",+ "emailAddress": "[email protected]",+ "slug": "zura",+ "id": 4,+ "name": "zura"+ },+ "id": 2,+ "updatedDate": 1553585861365,+ "tasks": [],+ "comments": [],+ "version": 4,+ "text": "This seems like a pretty good idea. @shimura what do you think?",+ "createdDate": 1553585547535+ },+ "actor": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/zura"+ }+ ]+ },+ "displayName": "Katsura Kotarou",+ "emailAddress": "[email protected]",+ "slug": "zura",+ "id": 4,+ "name": "zura"+ },+ "eventKey": "pr:comment:deleted",+ "date": "2019-03-26T13:08:41+0530",+ "pullRequest": {+ "locked": false,+ "state": "OPEN",+ "description": "Add a simple text file for further testing purposes.",+ "closed": false,+ "open": true,+ "title": "sample_file: Add sample_file.txt.",+ "toRef": {+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "id": "refs/heads/master",+ "displayId": "master",+ "latestCommit": "d46b4d2e3326e106147c0ea748f7defba29d9e1e"+ },+ "reviewers": [+ {+ "status": "UNAPPROVED",+ "role": "REVIEWER",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/sougo"+ }+ ]+ },+ "displayName": "Okita Sougo",+ "emailAddress": "[email protected]",+ "slug": "sougo",+ "id": 3,+ "name": "sougo"+ },+ "approved": false+ },+ {+ "status": "UNAPPROVED",+ "role": "REVIEWER",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/shimura"+ }+ ]+ },+ "displayName": "Shimura Shinpachi",+ "emailAddress": "[email protected]",+ "slug": "shimura",+ "id": 2,+ "name": "shimura"+ },+ "approved": false+ },+ {+ "status": "UNAPPROVED",+ "role": "REVIEWER",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/zura"+ }+ ]+ },+ "displayName": "Katsura Kotarou",+ "emailAddress": "[email protected]",+ "slug": "zura",+ "id": 4,+ "name": "zura"+ },+ "approved": false+ }+ ],+ "author": {+ "status": "UNAPPROVED",+ "role": "AUTHOR",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "approved": false+ },+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/6"+ }+ ]+ },+ "createdDate": 1553572666612,+ "fromRef": {+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/~hypro999/sandbox-fork.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/~hypro999/sandbox-fork.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999/repos/sandbox-fork/browse"+ }+ ]+ },+ "forkable": true,+ "origin": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "slug": "sandbox-fork",+ "project": {+ "key": "~HYPRO999",+ "type": "PERSONAL",+ "owner": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "id": 3,+ "name": "Hemanth V. Alluri"+ },+ "id": 4,+ "scmId": "git",+ "public": false,+ "name": "sandbox fork",+ "statusMessage": "Available"+ },+ "id": "refs/heads/master",+ "displayId": "master",+ "latestCommit": "556bde1a2442562568fce6016de570516ac1c4f6"+ },+ "version": 0,+ "id": 6,+ "updatedDate": 1553572666612,+ "participants": []+ }+}diff --git a/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_comment_edited.json b/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_comment_edited.jsonnew file mode 100644index 00000000000..1d1bdfb7cb7--- /dev/null+++ b/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_comment_edited.json@@ -0,0 +1,303 @@+{+ "actor": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/zura"+ }+ ]+ },+ "displayName": "Katsura Kotarou",+ "emailAddress": "[email protected]",+ "slug": "zura",+ "id": 4,+ "name": "zura"+ },+ "comment": {+ "author": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/zura"+ }+ ]+ },+ "displayName": "Katsura Kotarou",+ "emailAddress": "[email protected]",+ "slug": "zura",+ "id": 4,+ "name": "zura"+ },+ "id": 2,+ "updatedDate": 1553585861365,+ "tasks": [],+ "comments": [],+ "version": 4,+ "text": "This seems like a pretty good idea. @shimura what do you think?",+ "createdDate": 1553585547535,+ "properties": {+ "repositoryId": 2+ }+ },+ "previousComment": "This seems like a pretty good idea.",+ "pullRequest": {+ "locked": false,+ "state": "OPEN",+ "description": "Add a simple text file for further testing purposes.",+ "closed": false,+ "open": true,+ "title": "sample_file: Add sample_file.txt.",+ "toRef": {+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "id": "refs/heads/master",+ "displayId": "master",+ "latestCommit": "d46b4d2e3326e106147c0ea748f7defba29d9e1e"+ },+ "reviewers": [+ {+ "status": "UNAPPROVED",+ "role": "REVIEWER",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/sougo"+ }+ ]+ },+ "displayName": "Okita Sougo",+ "emailAddress": "[email protected]",+ "slug": "sougo",+ "id": 3,+ "name": "sougo"+ },+ "approved": false+ },+ {+ "status": "UNAPPROVED",+ "role": "REVIEWER",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/zura"+ }+ ]+ },+ "displayName": "Katsura Kotarou",+ "emailAddress": "[email protected]",+ "slug": "zura",+ "id": 4,+ "name": "zura"+ },+ "approved": false+ },+ {+ "status": "UNAPPROVED",+ "role": "REVIEWER",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/shimura"+ }+ ]+ },+ "displayName": "Shimura Shinpachi",+ "emailAddress": "[email protected]",+ "slug": "shimura",+ "id": 2,+ "name": "shimura"+ },+ "approved": false+ }+ ],+ "author": {+ "status": "UNAPPROVED",+ "role": "AUTHOR",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "approved": false+ },+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/6"+ }+ ]+ },+ "createdDate": 1553572666612,+ "fromRef": {+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/~hypro999/sandbox-fork.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/~hypro999/sandbox-fork.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999/repos/sandbox-fork/browse"+ }+ ]+ },+ "forkable": true,+ "origin": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "slug": "sandbox-fork",+ "project": {+ "key": "~HYPRO999",+ "type": "PERSONAL",+ "owner": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "id": 3,+ "name": "Hemanth V. Alluri"+ },+ "id": 4,+ "scmId": "git",+ "public": false,+ "name": "sandbox fork",+ "statusMessage": "Available"+ },+ "id": "refs/heads/master",+ "displayId": "master",+ "latestCommit": "556bde1a2442562568fce6016de570516ac1c4f6"+ },+ "version": 0,+ "id": 6,+ "updatedDate": 1553572666612,+ "participants": []+ },+ "eventKey": "pr:comment:edited",+ "date": "2019-03-26T13:07:41+0530"+}diff --git a/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_declined.json b/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_declined.jsonnew file mode 100644index 00000000000..d224d6dfd3a--- /dev/null+++ b/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_declined.json@@ -0,0 +1,254 @@+{+ "actor": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/zura"+ }+ ]+ },+ "displayName": "Katsura Kotarou",+ "emailAddress": "[email protected]",+ "slug": "zura",+ "id": 4,+ "name": "zura"+ },+ "eventKey": "pr:declined",+ "date": "2019-03-26T15:53:42+0530",+ "pullRequest": {+ "locked": false,+ "state": "DECLINED",+ "description": "I just got a crazy idea, how 'bout we just delete everything?",+ "closed": true,+ "open": false,+ "title": "Crazy Idea",+ "toRef": {+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "id": "refs/heads/master",+ "displayId": "master",+ "latestCommit": "1015204bf62881c5ef9e18e6e73e0211a667a00c"+ },+ "closedDate": 1553595822665,+ "reviewers": [+ {+ "status": "UNAPPROVED",+ "role": "REVIEWER",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/zura"+ }+ ]+ },+ "displayName": "Katsura Kotarou",+ "emailAddress": "[email protected]",+ "slug": "zura",+ "id": 4,+ "name": "zura"+ },+ "approved": false+ },+ {+ "status": "UNAPPROVED",+ "role": "REVIEWER",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/shimura"+ }+ ]+ },+ "displayName": "Shimura Shinpachi",+ "emailAddress": "[email protected]",+ "slug": "shimura",+ "id": 2,+ "name": "shimura"+ },+ "approved": false+ }+ ],+ "author": {+ "status": "UNAPPROVED",+ "role": "AUTHOR",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "approved": false+ },+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/7"+ }+ ]+ },+ "createdDate": 1553595372759,+ "fromRef": {+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/~hypro999/sandbox-fork.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/~hypro999/sandbox-fork.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999/repos/sandbox-fork/browse"+ }+ ]+ },+ "forkable": true,+ "origin": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "slug": "sandbox-fork",+ "project": {+ "key": "~HYPRO999",+ "type": "PERSONAL",+ "owner": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "id": 3,+ "name": "Hemanth V. Alluri"+ },+ "id": 4,+ "scmId": "git",+ "public": false,+ "name": "sandbox fork",+ "statusMessage": "Available"+ },+ "id": "refs/heads/crazy_idea",+ "displayId": "crazy_idea",+ "latestCommit": "dd17f2eaad634e292068ef7f353b3538334d31f1"+ },+ "version": 2,+ "id": 7,+ "updatedDate": 1553595822665,+ "participants": []+ }+}diff --git a/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_deleted.json b/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_deleted.jsonnew file mode 100644index 00000000000..812cb9e32d0--- /dev/null+++ b/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_deleted.json@@ -0,0 +1,209 @@+{+ "actor": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "eventKey": "pr:deleted",+ "date": "2019-03-21T19:29:49+0530",+ "pullRequest": {+ "locked": false,+ "state": "OPEN",+ "closed": false,+ "open": true,+ "title": "Add notes feature.",+ "toRef": {+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "id": "refs/heads/master",+ "displayId": "master",+ "latestCommit": "508d1b67f1f8f3a25f543a030a7a178894aa9907"+ },+ "reviewers": [],+ "author": {+ "status": "UNAPPROVED",+ "role": "AUTHOR",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "approved": false+ },+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/2"+ }+ ]+ },+ "createdDate": 1553176436660,+ "fromRef": {+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/~hypro999/sandbox-fork.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/~hypro999/sandbox-fork.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999/repos/sandbox-fork/browse"+ }+ ]+ },+ "forkable": true,+ "origin": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "slug": "sandbox-fork",+ "project": {+ "key": "~HYPRO999",+ "type": "PERSONAL",+ "owner": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "id": 3,+ "name": "Hemanth V. Alluri"+ },+ "id": 4,+ "scmId": "git",+ "public": false,+ "name": "sandbox fork",+ "statusMessage": "Available"+ },+ "id": "refs/heads/master",+ "displayId": "master",+ "latestCommit": "1a8de2fd34dcf6c9c2117b62eb17a266736aad7f"+ },+ "version": 0,+ "id": 2,+ "updatedDate": 1553176436660,+ "participants": []+ }+}diff --git a/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_merged.json b/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_merged.jsonnew file mode 100644index 00000000000..9982d91fb20--- /dev/null+++ b/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_merged.json@@ -0,0 +1,282 @@+{+ "actor": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/zura"+ }+ ]+ },+ "displayName": "Katsura Kotarou",+ "emailAddress": "[email protected]",+ "slug": "zura",+ "id": 4,+ "name": "zura"+ },+ "eventKey": "pr:merged",+ "date": "2019-03-26T15:52:24+0530",+ "pullRequest": {+ "locked": false,+ "state": "MERGED",+ "description": "Add a simple text file for further testing purposes.",+ "closed": true,+ "open": false,+ "title": "sample_file: Add sample_file.txt.",+ "toRef": {+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "id": "refs/heads/master",+ "displayId": "master",+ "latestCommit": "d46b4d2e3326e106147c0ea748f7defba29d9e1e"+ },+ "closedDate": 1553595743394,+ "reviewers": [+ {+ "status": "UNAPPROVED",+ "role": "REVIEWER",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/shimura"+ }+ ]+ },+ "displayName": "Shimura Shinpachi",+ "emailAddress": "[email protected]",+ "slug": "shimura",+ "id": 2,+ "name": "shimura"+ },+ "approved": false+ },+ {+ "status": "UNAPPROVED",+ "role": "REVIEWER",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/sougo"+ }+ ]+ },+ "displayName": "Okita Sougo",+ "emailAddress": "[email protected]",+ "slug": "sougo",+ "id": 3,+ "name": "sougo"+ },+ "approved": false+ },+ {+ "status": "APPROVED",+ "role": "REVIEWER",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/zura"+ }+ ]+ },+ "displayName": "Katsura Kotarou",+ "emailAddress": "[email protected]",+ "slug": "zura",+ "id": 4,+ "name": "zura"+ },+ "lastReviewedCommit": "556bde1a2442562568fce6016de570516ac1c4f6",+ "approved": true+ }+ ],+ "author": {+ "status": "UNAPPROVED",+ "role": "AUTHOR",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "approved": false+ },+ "properties": {+ "mergeCommit": {+ "id": "1015204bf62881c5ef9e18e6e73e0211a667a00c",+ "displayId": "1015204bf62"+ }+ },+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/6"+ }+ ]+ },+ "createdDate": 1553572666612,+ "fromRef": {+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/~hypro999/sandbox-fork.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/~hypro999/sandbox-fork.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999/repos/sandbox-fork/browse"+ }+ ]+ },+ "forkable": true,+ "origin": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "slug": "sandbox-fork",+ "project": {+ "key": "~HYPRO999",+ "type": "PERSONAL",+ "owner": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "id": 3,+ "name": "Hemanth V. Alluri"+ },+ "id": 4,+ "scmId": "git",+ "public": false,+ "name": "sandbox fork",+ "statusMessage": "Available"+ },+ "id": "refs/heads/master",+ "displayId": "master",+ "latestCommit": "556bde1a2442562568fce6016de570516ac1c4f6"+ },+ "version": 2,+ "id": 6,+ "updatedDate": 1553595743394,+ "participants": []+ }+}diff --git a/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_modified.json b/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_modified.jsonnew file mode 100644index 00000000000..7d79c9b91db--- /dev/null+++ b/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_modified.json@@ -0,0 +1,241 @@+{+ "actor": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "previousDescription": "* Add file2.txt\r\n* Add file3.txt",+ "pullRequest": {+ "locked": false,+ "state": "OPEN",+ "description": "* Add file2.txt\n* Add file3.txt\nBoth of these files would be important additions to the project!",+ "closed": false,+ "open": true,+ "title": "Branch1",+ "toRef": {+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "id": "refs/heads/master",+ "displayId": "master",+ "latestCommit": "508d1b67f1f8f3a25f543a030a7a178894aa9907"+ },+ "reviewers": [+ {+ "status": "UNAPPROVED",+ "role": "REVIEWER",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/shimura"+ }+ ]+ },+ "displayName": "Shimura Shinpachi",+ "emailAddress": "[email protected]",+ "slug": "shimura",+ "id": 2,+ "name": "shimura"+ },+ "approved": false+ }+ ],+ "author": {+ "status": "UNAPPROVED",+ "role": "AUTHOR",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "approved": false+ },+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/1"+ }+ ]+ },+ "createdDate": 1553172738844,+ "fromRef": {+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/~hypro999/sandbox-fork.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/~hypro999/sandbox-fork.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999/repos/sandbox-fork/browse"+ }+ ]+ },+ "forkable": true,+ "origin": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "slug": "sandbox-fork",+ "project": {+ "key": "~HYPRO999",+ "type": "PERSONAL",+ "owner": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "id": 3,+ "name": "Hemanth V. Alluri"+ },+ "id": 4,+ "scmId": "git",+ "public": false,+ "name": "sandbox fork",+ "statusMessage": "Available"+ },+ "id": "refs/heads/branch1",+ "displayId": "branch1",+ "latestCommit": "3980c2be32a7e23c795741d5dc1a2eecb9b85d6d"+ },+ "version": 1,+ "id": 1,+ "updatedDate": 1553337991505,+ "participants": []+ },+ "previousTitle": "Branch1",+ "previousTarget": {+ "latestChangeset": "508d1b67f1f8f3a25f543a030a7a178894aa9907",+ "type": "BRANCH",+ "id": "refs/heads/master",+ "displayId": "master",+ "latestCommit": "508d1b67f1f8f3a25f543a030a7a178894aa9907"+ },+ "eventKey": "pr:modified",+ "date": "2019-03-23T16:16:31+0530"+}diff --git a/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_needs_work.json b/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_needs_work.jsonnew file mode 100644index 00000000000..12ea2db5db7--- /dev/null+++ b/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_needs_work.json@@ -0,0 +1,298 @@+{+ "actor": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/zura"+ }+ ]+ },+ "displayName": "Katsura Kotarou",+ "emailAddress": "[email protected]",+ "slug": "zura",+ "id": 4,+ "name": "zura"+ },+ "previousStatus": "UNAPPROVED",+ "participant": {+ "status": "NEEDS_WORK",+ "role": "REVIEWER",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/zura"+ }+ ]+ },+ "displayName": "Katsura Kotarou",+ "emailAddress": "[email protected]",+ "slug": "zura",+ "id": 4,+ "name": "zura"+ },+ "lastReviewedCommit": "556bde1a2442562568fce6016de570516ac1c4f6",+ "approved": false+ },+ "pullRequest": {+ "locked": false,+ "state": "OPEN",+ "description": "Add a simple text file for further testing purposes.",+ "closed": false,+ "open": true,+ "title": "sample_file: Add sample_file.txt.",+ "toRef": {+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "id": "refs/heads/master",+ "displayId": "master",+ "latestCommit": "d46b4d2e3326e106147c0ea748f7defba29d9e1e"+ },+ "reviewers": [+ {+ "status": "UNAPPROVED",+ "role": "REVIEWER",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/sougo"+ }+ ]+ },+ "displayName": "Okita Sougo",+ "emailAddress": "[email protected]",+ "slug": "sougo",+ "id": 3,+ "name": "sougo"+ },+ "approved": false+ },+ {+ "status": "UNAPPROVED",+ "role": "REVIEWER",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/shimura"+ }+ ]+ },+ "displayName": "Shimura Shinpachi",+ "emailAddress": "[email protected]",+ "slug": "shimura",+ "id": 2,+ "name": "shimura"+ },+ "approved": false+ },+ {+ "status": "NEEDS_WORK",+ "role": "REVIEWER",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/zura"+ }+ ]+ },+ "displayName": "Katsura Kotarou",+ "emailAddress": "[email protected]",+ "slug": "zura",+ "id": 4,+ "name": "zura"+ },+ "lastReviewedCommit": "556bde1a2442562568fce6016de570516ac1c4f6",+ "approved": false+ }+ ],+ "author": {+ "status": "UNAPPROVED",+ "role": "AUTHOR",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "approved": false+ },+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/6"+ }+ ]+ },+ "createdDate": 1553572666612,+ "fromRef": {+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/~hypro999/sandbox-fork.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/~hypro999/sandbox-fork.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999/repos/sandbox-fork/browse"+ }+ ]+ },+ "forkable": true,+ "origin": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "slug": "sandbox-fork",+ "project": {+ "key": "~HYPRO999",+ "type": "PERSONAL",+ "owner": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "id": 3,+ "name": "Hemanth V. Alluri"+ },+ "id": 4,+ "scmId": "git",+ "public": false,+ "name": "sandbox fork",+ "statusMessage": "Available"+ },+ "id": "refs/heads/master",+ "displayId": "master",+ "latestCommit": "556bde1a2442562568fce6016de570516ac1c4f6"+ },+ "version": 0,+ "id": 6,+ "updatedDate": 1553572666612,+ "participants": []+ },+ "eventKey": "pr:reviewer:needs_work",+ "date": "2019-03-26T15:50:44+0530"+}diff --git a/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_opened_with_multiple_reviewers.json b/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_opened_with_multiple_reviewers.jsonnew file mode 100644index 00000000000..171e14d6d0b--- /dev/null+++ b/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_opened_with_multiple_reviewers.json@@ -0,0 +1,274 @@+{+ "actor": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "eventKey": "pr:opened",+ "date": "2019-03-26T09:27:46+0530",+ "pullRequest": {+ "locked": false,+ "state": "OPEN",+ "description": "Add a simple text file for further testing purposes.",+ "closed": false,+ "open": true,+ "title": "sample_file: Add sample_file.txt.",+ "toRef": {+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "id": "refs/heads/master",+ "displayId": "master",+ "latestCommit": "d46b4d2e3326e106147c0ea748f7defba29d9e1e"+ },+ "reviewers": [+ {+ "status": "UNAPPROVED",+ "role": "REVIEWER",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/sougo"+ }+ ]+ },+ "displayName": "Okita Sougo",+ "emailAddress": "[email protected]",+ "slug": "sougo",+ "id": 3,+ "name": "sougo"+ },+ "approved": false+ },+ {+ "status": "UNAPPROVED",+ "role": "REVIEWER",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/zura"+ }+ ]+ },+ "displayName": "Katsura Kotarou",+ "emailAddress": "[email protected]",+ "slug": "zura",+ "id": 4,+ "name": "zura"+ },+ "approved": false+ },+ {+ "status": "UNAPPROVED",+ "role": "REVIEWER",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/shimura"+ }+ ]+ },+ "displayName": "Shimura Shinpachi",+ "emailAddress": "[email protected]",+ "slug": "shimura",+ "id": 2,+ "name": "shimura"+ },+ "approved": false+ }+ ],+ "author": {+ "status": "UNAPPROVED",+ "role": "AUTHOR",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "approved": false+ },+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/6"+ }+ ]+ },+ "createdDate": 1553572666612,+ "fromRef": {+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/~hypro999/sandbox-fork.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/~hypro999/sandbox-fork.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999/repos/sandbox-fork/browse"+ }+ ]+ },+ "forkable": true,+ "origin": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "slug": "sandbox-fork",+ "project": {+ "key": "~HYPRO999",+ "type": "PERSONAL",+ "owner": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "id": 3,+ "name": "Hemanth V. Alluri"+ },+ "id": 4,+ "scmId": "git",+ "public": false,+ "name": "sandbox fork",+ "statusMessage": "Available"+ },+ "id": "refs/heads/master",+ "displayId": "master",+ "latestCommit": "556bde1a2442562568fce6016de570516ac1c4f6"+ },+ "version": 0,+ "id": 6,+ "updatedDate": 1553572666612,+ "participants": []+ }+}diff --git a/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_opened_with_two_reviewers.json b/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_opened_with_two_reviewers.jsonnew file mode 100644index 00000000000..c158f9193b4--- /dev/null+++ b/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_opened_with_two_reviewers.json@@ -0,0 +1,252 @@+{+ "actor": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "eventKey": "pr:opened",+ "date": "2019-03-24T13:54:58+0530",+ "pullRequest": {+ "locked": false,+ "state": "OPEN",+ "closed": false,+ "open": true,+ "title": "Add Notes Feature",+ "toRef": {+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "id": "refs/heads/master",+ "displayId": "master",+ "latestCommit": "508d1b67f1f8f3a25f543a030a7a178894aa9907"+ },+ "reviewers": [+ {+ "status": "UNAPPROVED",+ "role": "REVIEWER",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/shimura"+ }+ ]+ },+ "displayName": "Shimura Shinpachi",+ "emailAddress": "[email protected]",+ "slug": "shimura",+ "id": 2,+ "name": "shimura"+ },+ "approved": false+ },+ {+ "status": "UNAPPROVED",+ "role": "REVIEWER",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/sougo"+ }+ ]+ },+ "displayName": "Okita Sougo",+ "emailAddress": "[email protected]",+ "slug": "sougo",+ "id": 3,+ "name": "sougo"+ },+ "approved": false+ }+ ],+ "author": {+ "status": "UNAPPROVED",+ "role": "AUTHOR",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "approved": false+ },+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/5"+ }+ ]+ },+ "createdDate": 1553415897966,+ "fromRef": {+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/~hypro999/sandbox-fork.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/~hypro999/sandbox-fork.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999/repos/sandbox-fork/browse"+ }+ ]+ },+ "forkable": true,+ "origin": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "slug": "sandbox-fork",+ "project": {+ "key": "~HYPRO999",+ "type": "PERSONAL",+ "owner": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "id": 3,+ "name": "Hemanth V. Alluri"+ },+ "id": 4,+ "scmId": "git",+ "public": false,+ "name": "sandbox fork",+ "statusMessage": "Available"+ },+ "id": "refs/heads/master",+ "displayId": "master",+ "latestCommit": "1a8de2fd34dcf6c9c2117b62eb17a266736aad7f"+ },+ "version": 0,+ "id": 5,+ "updatedDate": 1553415897966,+ "participants": []+ }+}diff --git a/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_opened_without_description.json b/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_opened_without_description.jsonnew file mode 100644index 00000000000..6a1b67e45c0--- /dev/null+++ b/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_opened_without_description.json@@ -0,0 +1,209 @@+{+ "actor": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "eventKey": "pr:opened",+ "date": "2019-03-21T19:23:56+0530",+ "pullRequest": {+ "locked": false,+ "state": "OPEN",+ "closed": false,+ "open": true,+ "title": "Add notes feature.",+ "toRef": {+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "id": "refs/heads/master",+ "displayId": "master",+ "latestCommit": "508d1b67f1f8f3a25f543a030a7a178894aa9907"+ },+ "reviewers": [],+ "author": {+ "status": "UNAPPROVED",+ "role": "AUTHOR",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "approved": false+ },+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/2"+ }+ ]+ },+ "createdDate": 1553176436660,+ "fromRef": {+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/~hypro999/sandbox-fork.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/~hypro999/sandbox-fork.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999/repos/sandbox-fork/browse"+ }+ ]+ },+ "forkable": true,+ "origin": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "slug": "sandbox-fork",+ "project": {+ "key": "~HYPRO999",+ "type": "PERSONAL",+ "owner": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "id": 3,+ "name": "Hemanth V. Alluri"+ },+ "id": 4,+ "scmId": "git",+ "public": false,+ "name": "sandbox fork",+ "statusMessage": "Available"+ },+ "id": "refs/heads/master",+ "displayId": "master",+ "latestCommit": "1a8de2fd34dcf6c9c2117b62eb17a266736aad7f"+ },+ "version": 0,+ "id": 2,+ "updatedDate": 1553176436660,+ "participants": []+ }+}diff --git a/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_opened_without_reviewers.json b/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_opened_without_reviewers.jsonnew file mode 100644index 00000000000..3cb071841e0--- /dev/null+++ b/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_opened_without_reviewers.json@@ -0,0 +1,210 @@+{+ "actor": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "eventKey": "pr:opened",+ "date": "2019-03-21T18:22:20+0530",+ "pullRequest": {+ "locked": false,+ "state": "OPEN",+ "description": "* Add file2.txt\r\n* Add file3.txt",+ "closed": false,+ "open": true,+ "title": "Branch1",+ "toRef": {+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "id": "refs/heads/master",+ "displayId": "master",+ "latestCommit": "508d1b67f1f8f3a25f543a030a7a178894aa9907"+ },+ "reviewers": [],+ "author": {+ "status": "UNAPPROVED",+ "role": "AUTHOR",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "approved": false+ },+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/1"+ }+ ]+ },+ "createdDate": 1553172738844,+ "fromRef": {+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/~hypro999/sandbox-fork.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/~hypro999/sandbox-fork.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999/repos/sandbox-fork/browse"+ }+ ]+ },+ "forkable": true,+ "origin": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "slug": "sandbox-fork",+ "project": {+ "key": "~HYPRO999",+ "type": "PERSONAL",+ "owner": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "id": 3,+ "name": "Hemanth V. Alluri"+ },+ "id": 4,+ "scmId": "git",+ "public": false,+ "name": "sandbox fork",+ "statusMessage": "Available"+ },+ "id": "refs/heads/branch1",+ "displayId": "branch1",+ "latestCommit": "3980c2be32a7e23c795741d5dc1a2eecb9b85d6d"+ },+ "version": 0,+ "id": 1,+ "updatedDate": 1553172738844,+ "participants": []+ }+}diff --git a/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_remove_reviewer.json b/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_remove_reviewer.jsonnew file mode 100644index 00000000000..a4286f84b91--- /dev/null+++ b/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_remove_reviewer.json@@ -0,0 +1,229 @@+{+ "addedReviewers": [],+ "actor": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "pullRequest": {+ "locked": false,+ "state": "OPEN",+ "description": "* Add file2.txt\n* Add file3.txt\nBoth of these files would be important additions to the project!",+ "closed": false,+ "open": true,+ "title": "Branch1",+ "toRef": {+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "id": "refs/heads/master",+ "displayId": "master",+ "latestCommit": "508d1b67f1f8f3a25f543a030a7a178894aa9907"+ },+ "reviewers": [],+ "author": {+ "status": "UNAPPROVED",+ "role": "AUTHOR",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "approved": false+ },+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/1"+ }+ ]+ },+ "createdDate": 1553172738844,+ "fromRef": {+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/~hypro999/sandbox-fork.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/~hypro999/sandbox-fork.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999/repos/sandbox-fork/browse"+ }+ ]+ },+ "forkable": true,+ "origin": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "slug": "sandbox-fork",+ "project": {+ "key": "~HYPRO999",+ "type": "PERSONAL",+ "owner": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "id": 3,+ "name": "Hemanth V. Alluri"+ },+ "id": 4,+ "scmId": "git",+ "public": false,+ "name": "sandbox fork",+ "statusMessage": "Available"+ },+ "id": "refs/heads/branch1",+ "displayId": "branch1",+ "latestCommit": "91c9c6998c9768ca678048ddee7f9e480e6d54de"+ },+ "version": 3,+ "id": 1,+ "updatedDate": 1553340384837,+ "participants": []+ },+ "removedReviewers": [+ {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/shimura"+ }+ ]+ },+ "displayName": "Shimura Shinpachi",+ "emailAddress": "[email protected]",+ "slug": "shimura",+ "id": 2,+ "name": "shimura"+ }+ ],+ "eventKey": "pr:reviewer:updated",+ "date": "2019-03-23T16:56:25+0530"+}diff --git a/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_unapproved.json b/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_unapproved.jsonnew file mode 100644index 00000000000..769f472dbc1--- /dev/null+++ b/zerver/webhooks/bitbucketdatacenter/fixtures/pull_request_unapproved.json@@ -0,0 +1,298 @@+{+ "actor": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/zura"+ }+ ]+ },+ "displayName": "Katsura Kotarou",+ "emailAddress": "[email protected]",+ "slug": "zura",+ "id": 4,+ "name": "zura"+ },+ "previousStatus": "APPROVED",+ "participant": {+ "status": "UNAPPROVED",+ "role": "REVIEWER",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/zura"+ }+ ]+ },+ "displayName": "Katsura Kotarou",+ "emailAddress": "[email protected]",+ "slug": "zura",+ "id": 4,+ "name": "zura"+ },+ "lastReviewedCommit": "556bde1a2442562568fce6016de570516ac1c4f6",+ "approved": false+ },+ "pullRequest": {+ "locked": false,+ "state": "OPEN",+ "description": "Add a simple text file for further testing purposes.",+ "closed": false,+ "open": true,+ "title": "sample_file: Add sample_file.txt.",+ "toRef": {+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "id": "refs/heads/master",+ "displayId": "master",+ "latestCommit": "d46b4d2e3326e106147c0ea748f7defba29d9e1e"+ },+ "reviewers": [+ {+ "status": "UNAPPROVED",+ "role": "REVIEWER",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/shimura"+ }+ ]+ },+ "displayName": "Shimura Shinpachi",+ "emailAddress": "[email protected]",+ "slug": "shimura",+ "id": 2,+ "name": "shimura"+ },+ "approved": false+ },+ {+ "status": "UNAPPROVED",+ "role": "REVIEWER",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/zura"+ }+ ]+ },+ "displayName": "Katsura Kotarou",+ "emailAddress": "[email protected]",+ "slug": "zura",+ "id": 4,+ "name": "zura"+ },+ "lastReviewedCommit": "556bde1a2442562568fce6016de570516ac1c4f6",+ "approved": false+ },+ {+ "status": "UNAPPROVED",+ "role": "REVIEWER",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/sougo"+ }+ ]+ },+ "displayName": "Okita Sougo",+ "emailAddress": "[email protected]",+ "slug": "sougo",+ "id": 3,+ "name": "sougo"+ },+ "approved": false+ }+ ],+ "author": {+ "status": "UNAPPROVED",+ "role": "AUTHOR",+ "user": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "approved": false+ },+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/6"+ }+ ]+ },+ "createdDate": 1553572666612,+ "fromRef": {+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/~hypro999/sandbox-fork.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/~hypro999/sandbox-fork.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999/repos/sandbox-fork/browse"+ }+ ]+ },+ "forkable": true,+ "origin": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "slug": "sandbox-fork",+ "project": {+ "key": "~HYPRO999",+ "type": "PERSONAL",+ "owner": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "id": 3,+ "name": "Hemanth V. Alluri"+ },+ "id": 4,+ "scmId": "git",+ "public": false,+ "name": "sandbox fork",+ "statusMessage": "Available"+ },+ "id": "refs/heads/master",+ "displayId": "master",+ "latestCommit": "556bde1a2442562568fce6016de570516ac1c4f6"+ },+ "version": 0,+ "id": 6,+ "updatedDate": 1553572666612,+ "participants": []+ },+ "eventKey": "pr:reviewer:unapproved",+ "date": "2019-03-26T15:49:39+0530"+}diff --git a/zerver/webhooks/bitbucketdatacenter/fixtures/repo_forked.json b/zerver/webhooks/bitbucketdatacenter/fixtures/repo_forked.jsonnew file mode 100644index 00000000000..651f9368211--- /dev/null+++ b/zerver/webhooks/bitbucketdatacenter/fixtures/repo_forked.json@@ -0,0 +1,117 @@+{+ "actor": {+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "active": true,+ "slug": "hypro999",+ "type": "NORMAL",+ "name": "hypro999",+ "id": 1,+ "emailAddress": "[email protected]"+ },+ "repository": {+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/~hypro999/sandbox-fork.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/~hypro999/sandbox-fork.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999/repos/sandbox-fork/browse"+ }+ ]+ },+ "statusMessage": "Available",+ "id": 4,+ "slug": "sandbox-fork",+ "project": {+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "owner": {+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "active": true,+ "slug": "hypro999",+ "type": "NORMAL",+ "name": "hypro999",+ "id": 1,+ "emailAddress": "[email protected]"+ },+ "key": "~HYPRO999",+ "type": "PERSONAL",+ "name": "Hemanth V. Alluri",+ "id": 3+ },+ "origin": {+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "statusMessage": "Available",+ "id": 2,+ "slug": "sandbox",+ "project": {+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "key": "SBOX",+ "type": "NORMAL",+ "name": "Sandbox",+ "id": 2,+ "public": false+ },+ "name": "sandbox",+ "state": "AVAILABLE",+ "forkable": true,+ "scmId": "git",+ "public": false+ },+ "name": "sandbox fork",+ "state": "AVAILABLE",+ "forkable": true,+ "scmId": "git",+ "public": false+ },+ "date": "2019-03-08T12:25:34+0530",+ "eventKey": "repo:forked"+}diff --git a/zerver/webhooks/bitbucketdatacenter/fixtures/repo_modified.json b/zerver/webhooks/bitbucketdatacenter/fixtures/repo_modified.jsonnew file mode 100644index 00000000000..9489f6d516f--- /dev/null+++ b/zerver/webhooks/bitbucketdatacenter/fixtures/repo_modified.json@@ -0,0 +1,102 @@+{+ "actor": {+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "active": true,+ "slug": "hypro999",+ "type": "NORMAL",+ "name": "hypro999",+ "id": 1,+ "emailAddress": "[email protected]"+ },+ "old": {+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox-v2.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox-v2.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "statusMessage": "Available",+ "id": 2,+ "slug": "sandbox",+ "project": {+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "key": "SBOX",+ "type": "NORMAL",+ "name": "Sandbox",+ "id": 2,+ "public": false+ },+ "name": "sandbox",+ "state": "AVAILABLE",+ "forkable": true,+ "scmId": "git",+ "public": false+ },+ "date": "2019-03-08T18:20:26+0530",+ "eventKey": "repo:modified",+ "new": {+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox-v2.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox-v2.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox-v2/browse"+ }+ ]+ },+ "statusMessage": "Available",+ "id": 2,+ "slug": "sandbox-v2",+ "project": {+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "key": "SBOX",+ "type": "NORMAL",+ "name": "Sandbox",+ "id": 2,+ "public": false+ },+ "name": "sandbox v2",+ "state": "AVAILABLE",+ "forkable": true,+ "scmId": "git",+ "public": false+ }+}diff --git a/zerver/webhooks/bitbucketdatacenter/fixtures/repo_push_add_branch.json b/zerver/webhooks/bitbucketdatacenter/fixtures/repo_push_add_branch.jsonnew file mode 100644index 00000000000..6cb86f6613f--- /dev/null+++ b/zerver/webhooks/bitbucketdatacenter/fixtures/repo_push_add_branch.json@@ -0,0 +1,74 @@+{+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "actor": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "eventKey": "repo:refs_changed",+ "date": "2019-03-21T09:37:33+0530",+ "changes": [+ {+ "toHash": "c7fccd35e163571148c42a3e8b11aef6661d19b8",+ "type": "ADD",+ "ref": {+ "type": "BRANCH",+ "id": "refs/heads/branch2",+ "displayId": "branch2"+ },+ "fromHash": "0000000000000000000000000000000000000000",+ "refId": "refs/heads/branch2"+ }+ ]+}diff --git a/zerver/webhooks/bitbucketdatacenter/fixtures/repo_push_add_tag.json b/zerver/webhooks/bitbucketdatacenter/fixtures/repo_push_add_tag.jsonnew file mode 100644index 00000000000..cf99d0c7c56--- /dev/null+++ b/zerver/webhooks/bitbucketdatacenter/fixtures/repo_push_add_tag.json@@ -0,0 +1,74 @@+{+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "actor": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "eventKey": "repo:refs_changed",+ "date": "2019-03-17T22:41:19+0530",+ "changes": [+ {+ "toHash": "9b5565bec1d0e8d5d60d423fe70b54849d3aacc4",+ "type": "ADD",+ "ref": {+ "type": "TAG",+ "id": "refs/tags/newtag",+ "displayId": "newtag"+ },+ "fromHash": "0000000000000000000000000000000000000000",+ "refId": "refs/tags/newtag"+ }+ ]+}diff --git a/zerver/webhooks/bitbucketdatacenter/fixtures/repo_push_delete_branch.json b/zerver/webhooks/bitbucketdatacenter/fixtures/repo_push_delete_branch.jsonnew file mode 100644index 00000000000..3c9638527aa--- /dev/null+++ b/zerver/webhooks/bitbucketdatacenter/fixtures/repo_push_delete_branch.json@@ -0,0 +1,74 @@+{+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "actor": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "eventKey": "repo:refs_changed",+ "date": "2019-03-21T09:44:17+0530",+ "changes": [+ {+ "toHash": "0000000000000000000000000000000000000000",+ "type": "DELETE",+ "ref": {+ "type": "BRANCH",+ "id": "refs/heads/branch2",+ "displayId": "branch2"+ },+ "fromHash": "c7fccd35e163571148c42a3e8b11aef6661d19b8",+ "refId": "refs/heads/branch2"+ }+ ]+}diff --git a/zerver/webhooks/bitbucketdatacenter/fixtures/repo_push_delete_tag.json b/zerver/webhooks/bitbucketdatacenter/fixtures/repo_push_delete_tag.jsonnew file mode 100644index 00000000000..8f83ba98ffc--- /dev/null+++ b/zerver/webhooks/bitbucketdatacenter/fixtures/repo_push_delete_tag.json@@ -0,0 +1,74 @@+{+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "actor": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "eventKey": "repo:refs_changed",+ "date": "2019-03-21T09:54:37+0530",+ "changes": [+ {+ "toHash": "0000000000000000000000000000000000000000",+ "type": "DELETE",+ "ref": {+ "type": "TAG",+ "id": "refs/tags/test-tag",+ "displayId": "test-tag"+ },+ "fromHash": "b223099667fb4f71dd4f6f7d61cd2b7cdb184b37",+ "refId": "refs/tags/test-tag"+ }+ ]+}diff --git a/zerver/webhooks/bitbucketdatacenter/fixtures/repo_push_update_multiple_branches.json b/zerver/webhooks/bitbucketdatacenter/fixtures/repo_push_update_multiple_branches.jsonnew file mode 100644index 00000000000..653d91a7753--- /dev/null+++ b/zerver/webhooks/bitbucketdatacenter/fixtures/repo_push_update_multiple_branches.json@@ -0,0 +1,85 @@+{+ "repository": {+ "state": "AVAILABLE",+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "forkable": true,+ "slug": "sandbox",+ "project": {+ "key": "SBOX",+ "public": false,+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "id": 2,+ "type": "NORMAL",+ "name": "Sandbox"+ },+ "id": 2,+ "scmId": "git",+ "public": false,+ "name": "sandbox",+ "statusMessage": "Available"+ },+ "actor": {+ "active": true,+ "type": "NORMAL",+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "emailAddress": "[email protected]",+ "slug": "hypro999",+ "id": 1,+ "name": "hypro999"+ },+ "eventKey": "repo:refs_changed",+ "date": "2019-03-17T19:09:40+0530",+ "changes": [+ {+ "toHash": "3980c2be32a7e23c795741d5dc1a2eecb9b85d6d",+ "type": "UPDATE",+ "ref": {+ "type": "BRANCH",+ "id": "refs/heads/branch1",+ "displayId": "branch1"+ },+ "fromHash": "9e5afb9f11a396eae4bf24755505d931b530649a",+ "refId": "refs/heads/branch1"+ },+ {+ "toHash": "fc43d13cff1abb28631196944ba4fc4ad06a2cf2",+ "type": "UPDATE",+ "ref": {+ "type": "BRANCH",+ "id": "refs/heads/master",+ "displayId": "master"+ },+ "fromHash": "cb2e368ba3aca8a510f89667ae97b56d6a323db7",+ "refId": "refs/heads/master"+ }+ ]+}diff --git a/zerver/webhooks/bitbucketdatacenter/fixtures/repo_push_update_single_branch.json b/zerver/webhooks/bitbucketdatacenter/fixtures/repo_push_update_single_branch.jsonnew file mode 100644index 00000000000..7c7f41858f6--- /dev/null+++ b/zerver/webhooks/bitbucketdatacenter/fixtures/repo_push_update_single_branch.json@@ -0,0 +1,74 @@+{+ "actor": {+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/users/hypro999"+ }+ ]+ },+ "displayName": "Hemanth V. Alluri",+ "active": true,+ "slug": "hypro999",+ "type": "NORMAL",+ "name": "hypro999",+ "id": 1,+ "emailAddress": "[email protected]"+ },+ "repository": {+ "links": {+ "clone": [+ {+ "href": "ssh://[email protected]:7999/sbox/sandbox.git",+ "name": "ssh"+ },+ {+ "href": "http://139.59.64.214:7990/scm/sbox/sandbox.git",+ "name": "http"+ }+ ],+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX/repos/sandbox/browse"+ }+ ]+ },+ "statusMessage": "Available",+ "id": 2,+ "slug": "sandbox",+ "project": {+ "links": {+ "self": [+ {+ "href": "http://139.59.64.214:7990/projects/SBOX"+ }+ ]+ },+ "key": "SBOX",+ "type": "NORMAL",+ "name": "Sandbox",+ "id": 2,+ "public": false+ },+ "name": "sandbox",+ "state": "AVAILABLE",+ "forkable": true,+ "scmId": "git",+ "public": false+ },+ "date": "2019-03-17T18:15:52+0530",+ "eventKey": "repo:refs_changed",+ "changes": [+ {+ "ref": {+ "id": "refs/heads/master",+ "displayId": "master",+ "type": "BRANCH"+ },+ "toHash": "e68c981ef53dbab0a5ca320a2d8d80e216c70528",+ "refId": "refs/heads/master",+ "fromHash": "7c4cae30d77990b9095024bdd6c7bf0d545d870b",+ "type": "UPDATE"+ }+ ]+}diff --git a/zerver/webhooks/bitbucketdatacenter/tests.py b/zerver/webhooks/bitbucketdatacenter/tests.pynew file mode 100644index 00000000000..f10daaf60ac--- /dev/null+++ b/zerver/webhooks/bitbucketdatacenter/tests.py@@ -0,0 +1,266 @@+from zerver.lib.test_classes import WebhookTestCase++TOPIC = "sandbox"+TOPIC_BRANCH_EVENTS = "sandbox / {branch}"+++class BitbucketDataCenterHookTests(WebhookTestCase):+ def test_legacy_urls(self) -> None:+ expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) pushed to branch master. Head is now e68c981ef53dbab0a5ca320a2d8d80e216c70528."""+ expected_topic_name = TOPIC_BRANCH_EVENTS.format(branch="master")++ legacy_names = ["bitbucket3"]+ for legacy_name in legacy_names:+ self.url = self.build_webhook_url(legacy_name=legacy_name)+ self.check_webhook(+ "repo_push_update_single_branch", expected_topic_name, expected_message+ )++ # Diagnostics events:+ def test_ping(self) -> None:+ expected_message = (+ "Congratulations! The Bitbucket Data Center webhook was configured successfully!"+ )+ self.check_webhook("diagnostics_ping", "Bitbucket Data Center Ping", expected_message)++ def test_ping_with_user_defined_topic(self) -> None:+ self.url = self.build_webhook_url(topic="my topic")+ expected_message = (+ "Congratulations! The Bitbucket Data Center webhook was configured successfully!"+ )+ self.check_webhook("diagnostics_ping", "my topic", expected_message)++ # Core repo events:+ def test_commit_comment_added(self) -> None:+ expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) commented on [508d1b67f1f](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/commits/508d1b67f1f8f3a25f543a030a7a178894aa9907):\n``` quote\nJust an arbitrary comment on a commit.\n```"""+ self.check_webhook("commit_comment_added", TOPIC, expected_message)++ def test_commit_comment_edited(self) -> None:+ expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) edited their comment on [508d1b67f1f](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/commits/508d1b67f1f8f3a25f543a030a7a178894aa9907):\n``` quote\nJust an arbitrary comment on a commit. Nothing to see here...\n```"""+ self.check_webhook("commit_comment_edited", TOPIC, expected_message)++ def test_commit_comment_deleted(self) -> None:+ expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) deleted their comment on [508d1b67f1f](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/commits/508d1b67f1f8f3a25f543a030a7a178894aa9907):\n``` quote\n~~Just an arbitrary comment on a commit. Nothing to see here...~~\n```"""+ self.check_webhook("commit_comment_deleted", TOPIC, expected_message)++ def test_repo_forked(self) -> None:+ expected_message = """User Hemanth V. Alluri(login: [hypro999](http://139.59.64.214:7990/users/hypro999)) forked the repository into [sandbox fork](http://139.59.64.214:7990/users/hypro999/repos/sandbox-fork/browse)."""+ self.check_webhook("repo_forked", TOPIC, expected_message)++ def test_repo_modified(self) -> None:+ expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) changed the name of the **sandbox** repo from **sandbox** to **sandbox v2**."""+ expected_topic_name = "sandbox v2"+ self.check_webhook("repo_modified", expected_topic_name, expected_message)++ # Repo push events:+ def test_push_add_branch(self) -> None:+ expected_message = (+ """[hypro999](http://139.59.64.214:7990/users/hypro999) created branch2 branch."""+ )+ expected_topic_name = TOPIC_BRANCH_EVENTS.format(branch="branch2")+ self.check_webhook("repo_push_add_branch", expected_topic_name, expected_message)++ def test_push_add_tag(self) -> None:+ expected_message = (+ """[hypro999](http://139.59.64.214:7990/users/hypro999) pushed tag newtag."""+ )+ self.check_webhook("repo_push_add_tag", TOPIC, expected_message)++ def test_push_delete_branch(self) -> None:+ expected_message = (+ """[hypro999](http://139.59.64.214:7990/users/hypro999) deleted branch branch2."""+ )+ expected_topic_name = TOPIC_BRANCH_EVENTS.format(branch="branch2")+ self.check_webhook("repo_push_delete_branch", expected_topic_name, expected_message)++ def test_push_delete_tag(self) -> None:+ expected_message = (+ """[hypro999](http://139.59.64.214:7990/users/hypro999) removed tag test-tag."""+ )+ self.check_webhook("repo_push_delete_tag", TOPIC, expected_message)++ def test_push_update_single_branch(self) -> None:+ expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) pushed to branch master. Head is now e68c981ef53dbab0a5ca320a2d8d80e216c70528."""+ expected_topic_name = TOPIC_BRANCH_EVENTS.format(branch="master")+ self.check_webhook("repo_push_update_single_branch", expected_topic_name, expected_message)++ def test_push_update_multiple_branches(self) -> None:+ branch1_content = """[hypro999](http://139.59.64.214:7990/users/hypro999) pushed to branch branch1. Head is now 3980c2be32a7e23c795741d5dc1a2eecb9b85d6d."""+ master_content = """[hypro999](http://139.59.64.214:7990/users/hypro999) pushed to branch master. Head is now fc43d13cff1abb28631196944ba4fc4ad06a2cf2."""++ self.subscribe(self.test_user, self.channel_name)+ payload = self.get_body("repo_push_update_multiple_branches")++ msg = self.send_webhook_payload(+ self.test_user,+ self.url,+ payload,+ content_type="application/json",+ )++ msg = self.get_second_to_last_message()+ self.assert_channel_message(+ message=msg,+ channel_name=self.channel_name,+ topic_name=TOPIC_BRANCH_EVENTS.format(branch="branch1"),+ content=branch1_content,+ )++ msg = self.get_last_message()+ self.assert_channel_message(+ message=msg,+ channel_name=self.channel_name,+ topic_name=TOPIC_BRANCH_EVENTS.format(branch="master"),+ content=master_content,+ )++ def test_push_update_multiple_branches_with_branch_filter(self) -> None:+ self.url = self.build_webhook_url(branches="master")+ expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) pushed to branch master. Head is now fc43d13cff1abb28631196944ba4fc4ad06a2cf2."""+ expected_topic_name = TOPIC_BRANCH_EVENTS.format(branch="master")+ self.check_webhook(+ "repo_push_update_multiple_branches", expected_topic_name, expected_message+ )++ self.url = self.build_webhook_url(branches="branch1")+ expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) pushed to branch branch1. Head is now 3980c2be32a7e23c795741d5dc1a2eecb9b85d6d."""+ expected_topic_name = TOPIC_BRANCH_EVENTS.format(branch="branch1")+ self.check_webhook(+ "repo_push_update_multiple_branches", expected_topic_name, expected_message+ )++ # Core PR events:+ def test_pr_opened_without_reviewers(self) -> None:+ expected_topic_name = "sandbox / PR #1 Branch1"+ expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) opened [PR #1](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/1) from `branch1` to `master`:\n\n``` quote\n* Add file2.txt\r\n* Add file3.txt\n```"""+ self.check_webhook(+ "pull_request_opened_without_reviewers", expected_topic_name, expected_message+ )++ def test_pr_opened_without_description(self) -> None:+ expected_topic_name = "sandbox / PR #2 Add notes feature."+ expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) opened [PR #2](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/2) from `master` to `master`."""+ self.check_webhook(+ "pull_request_opened_without_description", expected_topic_name, expected_message+ )++ def test_pr_opened_with_two_reviewers(self) -> None:+ expected_topic_name = "sandbox / PR #5 Add Notes Feature"+ expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) opened [PR #5](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/5) from `master` to `master` (assigned reviewers: [shimura](http://139.59.64.214:7990/users/shimura) and [sougo](http://139.59.64.214:7990/users/sougo))."""+ self.check_webhook(+ "pull_request_opened_with_two_reviewers", expected_topic_name, expected_message+ )++ def test_pr_opened_with_two_reviewers_and_user_defined_topic(self) -> None:+ expected_topic_name = "sandbox / PR #5 Add Notes Feature"+ expected_topic_name = "custom_topic"+ self.url = self.build_webhook_url(topic="custom_topic")+ expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) opened [PR #5 Add Notes Feature](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/5) from `master` to `master` (assigned reviewers: [shimura](http://139.59.64.214:7990/users/shimura) and [sougo](http://139.59.64.214:7990/users/sougo))."""+ self.check_webhook(+ "pull_request_opened_with_two_reviewers", expected_topic_name, expected_message+ )++ def test_pr_opened_with_multiple_reviewers(self) -> None:+ expected_topic_name = "sandbox / PR #6 sample_file: Add sample_file.txt."+ expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) opened [PR #6](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/6) from `master` to `master` (assigned reviewers: [sougo](http://139.59.64.214:7990/users/sougo), [zura](http://139.59.64.214:7990/users/zura) and [shimura](http://139.59.64.214:7990/users/shimura)):\n\n``` quote\nAdd a simple text file for further testing purposes.\n```"""+ self.check_webhook(+ "pull_request_opened_with_multiple_reviewers", expected_topic_name, expected_message+ )++ def test_pr_modified(self) -> None:+ expected_topic_name = "sandbox / PR #1 Branch1"+ expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) modified [PR #1](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/1) (assigned reviewers: [shimura](http://139.59.64.214:7990/users/shimura)):\n\n``` quote\n* Add file2.txt\n* Add file3.txt\nBoth of these files would be important additions to the project!\n```"""+ self.check_webhook("pull_request_modified", expected_topic_name, expected_message)++ def test_pr_modified_with_include_title(self) -> None:+ expected_topic_name = "custom_topic"+ expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) modified [PR #1 Branch1](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/1) (assigned reviewers: [shimura](http://139.59.64.214:7990/users/shimura)):\n\n``` quote\n* Add file2.txt\n* Add file3.txt\nBoth of these files would be important additions to the project!\n```"""+ self.url = self.build_webhook_url(topic="custom_topic")+ self.check_webhook("pull_request_modified", expected_topic_name, expected_message)++ def test_pr_deleted(self) -> None:+ expected_topic_name = "sandbox / PR #2 Add notes feature."+ expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) deleted [PR #2](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/2)."""+ self.check_webhook("pull_request_deleted", expected_topic_name, expected_message)++ def test_pr_deleted_with_include_title(self) -> None:+ expected_topic_name = "custom_topic"+ expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) deleted [PR #2 Add notes feature.](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/2)"""+ self.url = self.build_webhook_url(topic="custom_topic")+ self.check_webhook("pull_request_deleted", expected_topic_name, expected_message)++ def test_pr_declined(self) -> None:+ expected_topic_name = "sandbox / PR #7 Crazy Idea"+ expected_message = """[zura](http://139.59.64.214:7990/users/zura) declined [PR #7](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/7)."""+ self.check_webhook("pull_request_declined", expected_topic_name, expected_message)++ def test_pr_merged(self) -> None:+ expected_topic_name = "sandbox / PR #6 sample_file: Add sample_file.txt."+ expected_message = """[zura](http://139.59.64.214:7990/users/zura) merged [PR #6](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/6) from `master` to `master`."""+ self.check_webhook("pull_request_merged", expected_topic_name, expected_message)++ # PR reviewer events:+ def test_pr_approved(self) -> None:+ expected_topic_name = "sandbox / PR #6 sample_file: Add sample_file.txt."+ expected_message = """[zura](http://139.59.64.214:7990/users/zura) approved [PR #6](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/6)."""+ self.check_webhook("pull_request_approved", expected_topic_name, expected_message)++ def test_pr_unapproved(self) -> None:+ expected_topic_name = "sandbox / PR #6 sample_file: Add sample_file.txt."+ expected_message = """[zura](http://139.59.64.214:7990/users/zura) unapproved [PR #6](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/6)."""+ self.check_webhook("pull_request_unapproved", expected_topic_name, expected_message)++ def test_pr_marked_as_needs_review(self) -> None:+ expected_topic_name = "sandbox / PR #6 sample_file: Add sample_file.txt."+ expected_message = """[zura](http://139.59.64.214:7990/users/zura) marked [PR #6](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/6) as \"needs work\"."""+ self.check_webhook("pull_request_needs_work", expected_topic_name, expected_message)++ def test_pr_marked_as_needs_review_and_include_title(self) -> None:+ expected_topic_name = "custom_topic"+ expected_message = """[zura](http://139.59.64.214:7990/users/zura) marked [PR #6 sample_file: Add sample_file.txt.](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/6) as \"needs work\"."""+ self.url = self.build_webhook_url(topic="custom_topic")+ self.check_webhook("pull_request_needs_work", expected_topic_name, expected_message)++ def test_pull_request_reviewer_added(self) -> None:+ expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) reassigned [PR #1](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/1) to [shimura](http://139.59.64.214:7990/users/shimura)."""+ expected_topic_name = "sandbox / PR #1 Branch1"+ self.check_webhook("pull_request_add_reviewer", expected_topic_name, expected_message)++ def test_pull_request_reviewer_added_and_include_title(self) -> None:+ expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) reassigned [PR #1 Branch1](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/1) to [shimura](http://139.59.64.214:7990/users/shimura)."""+ expected_topic_name = "custom_topic"+ self.url = self.build_webhook_url(topic="custom_topic")+ self.check_webhook("pull_request_add_reviewer", expected_topic_name, expected_message)++ def test_pull_request_reviewers_added(self) -> None:+ expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) reassigned [PR #1](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/1) to [shimura](http://139.59.64.214:7990/users/shimura) and [sougo](http://139.59.64.214:7990/users/sougo)."""+ expected_topic_name = "sandbox / PR #1 Branch1"+ self.check_webhook("pull_request_add_two_reviewers", expected_topic_name, expected_message)++ def test_pull_request_remove_all_reviewers(self) -> None:+ expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) removed all reviewers from [PR #1](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/1)."""+ expected_topic_name = "sandbox / PR #1 Branch1"+ self.check_webhook("pull_request_remove_reviewer", expected_topic_name, expected_message)++ def test_pull_request_remove_all_reviewers_with_title(self) -> None:+ expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) removed all reviewers from [PR #1 Branch1](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/1)."""+ expected_topic_name = "sandbox / PR #1 Branch1"+ expected_topic_name = "custom_topic"+ self.url = self.build_webhook_url(topic="custom_topic")+ self.check_webhook("pull_request_remove_reviewer", expected_topic_name, expected_message)++ # PR comment events:+ def test_pull_request_comment_added(self) -> None:+ expected_message = """[zura](http://139.59.64.214:7990/users/zura) commented on [PR #6](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/6):\n\n``` quote\nThis seems like a pretty good idea.\n```"""+ expected_topic_name = "sandbox / PR #6 sample_file: Add sample_file.txt."+ self.check_webhook("pull_request_comment_added", expected_topic_name, expected_message)++ def test_pull_request_comment_edited(self) -> None:+ expected_message = """[zura](http://139.59.64.214:7990/users/zura) edited their comment on [PR #6](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/6):\n\n``` quote\nThis seems like a pretty good idea. @shimura what do you think?\n```"""+ expected_topic_name = "sandbox / PR #6 sample_file: Add sample_file.txt."+ self.check_webhook("pull_request_comment_edited", expected_topic_name, expected_message)++ def test_pull_request_comment_deleted(self) -> None:+ expected_message = """[zura](http://139.59.64.214:7990/users/zura) deleted their comment on [PR #6](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/6):\n\n``` quote\n~~This seems like a pretty good idea. @shimura what do you think?~~\n```"""+ expected_topic_name = "sandbox / PR #6 sample_file: Add sample_file.txt."+ self.check_webhook("pull_request_comment_deleted", expected_topic_name, expected_message)diff --git a/zerver/webhooks/bitbucketdatacenter/view.py b/zerver/webhooks/bitbucketdatacenter/view.pynew file mode 100644index 00000000000..4fe8674452d--- /dev/null+++ b/zerver/webhooks/bitbucketdatacenter/view.py@@ -0,0 +1,455 @@+import string+from typing import Protocol++from django.http import HttpRequest, HttpResponse++from zerver.decorator import webhook_view+from zerver.lib.exceptions import UnsupportedWebhookEventTypeError+from zerver.lib.partial import partial+from zerver.lib.response import json_success+from zerver.lib.typed_endpoint import JsonBodyPayload, typed_endpoint+from zerver.lib.validator import WildValue, check_int, check_none_or, check_string+from zerver.lib.webhooks.common import (+ OptionalUserSpecifiedTopicStr,+ check_send_webhook_message,+ get_event_header,+)+from zerver.lib.webhooks.git import (+ TOPIC_WITH_BRANCH_TEMPLATE,+ TOPIC_WITH_PR_OR_ISSUE_INFO_TEMPLATE,+ get_commits_comment_action_message,+ get_create_branch_event_message,+ get_pull_request_event_message,+ get_push_tag_event_message,+ get_remove_branch_event_message,+ is_branch_name_notifiable,+)+from zerver.models import UserProfile+from zerver.webhooks.bitbucket.view import BITBUCKET_REPO_UPDATED_CHANGED, BITBUCKET_TOPIC_TEMPLATE++BITBUCKET_FORK_BODY = (+ "User {display_name}(login: {username}) forked the repository into [{fork_name}]({fork_url})."+)+BRANCH_UPDATED_MESSAGE_TEMPLATE = "{user_name} pushed to branch {branch_name}. Head is now {head}."+PULL_REQUEST_MARKED_AS_NEEDS_WORK_TEMPLATE = (+ '{user_name} marked [PR #{number}]({url}) as "needs work".'+)+PULL_REQUEST_MARKED_AS_NEEDS_WORK_TEMPLATE_WITH_TITLE = """+{user_name} marked [PR #{number} {title}]({url}) as \"needs work\".+""".strip()+PULL_REQUEST_REASSIGNED_TEMPLATE = "{user_name} reassigned [PR #{number}]({url}) to {assignees}."+PULL_REQUEST_REASSIGNED_TEMPLATE_WITH_TITLE = """+{user_name} reassigned [PR #{number} {title}]({url}) to {assignees}.+""".strip()+PULL_REQUEST_REASSIGNED_TO_NONE_TEMPLATE = (+ "{user_name} removed all reviewers from [PR #{number}]({url})."+)+PULL_REQUEST_REASSIGNED_TO_NONE_TEMPLATE_WITH_TITLE = """+{user_name} removed all reviewers from [PR #{number} {title}]({url})+""".strip()+PULL_REQUEST_OPENED_OR_MODIFIED_TEMPLATE_WITH_REVIEWERS = """+{user_name} {action} [PR #{number}]({url}) from `{source}` to \+`{destination}` (assigned to {assignees} for review)+""".strip()+PULL_REQUEST_OPENED_OR_MODIFIED_TEMPLATE_WITH_REVIEWERS_WITH_TITLE = """+{user_name} {action} [PR #{number} {title}]({url}) from `{source}` to \+`{destination}` (assigned to {assignees} for review)+""".strip()+++def fixture_to_headers(fixture_name: str) -> dict[str, str]:+ if fixture_name == "diagnostics_ping":+ return {"HTTP_X_EVENT_KEY": "diagnostics:ping"}+ return {}+++def get_user_name(payload: WildValue) -> str:+ user_name = "[{name}]({url})".format(+ name=payload["actor"]["name"].tame(check_string),+ url=payload["actor"]["links"]["self"][0]["href"].tame(check_string),+ )+ return user_name+++def ping_handler(+ payload: WildValue,+ branches: str | None,+ include_title: str | None,+) -> list[dict[str, str]]:+ if include_title:+ topic_name = include_title+ else:+ topic_name = "Bitbucket Data Center Ping"+ body = "Congratulations! The Bitbucket Data Center webhook was configured successfully!"+ return [{"topic": topic_name, "body": body}]+++def repo_comment_handler(+ action: str,+ payload: WildValue,+ branches: str | None,+ include_title: str | None,+) -> list[dict[str, str]]:+ repo_name = payload["repository"]["name"].tame(check_string)+ topic_name = BITBUCKET_TOPIC_TEMPLATE.format(repository_name=repo_name)+ sha = payload["commit"].tame(check_string)+ commit_url = (+ payload["repository"]["links"]["self"][0]["href"].tame(check_string).removesuffix("browse")+ )+ commit_url += f"commits/{sha}"+ message = payload["comment"]["text"].tame(check_string)+ if action == "deleted their comment":+ message = f"~~{message}~~"+ body = get_commits_comment_action_message(+ user_name=get_user_name(payload),+ action=action,+ commit_url=commit_url,+ sha=sha,+ message=message,+ )+ return [{"topic": topic_name, "body": body}]+++def repo_forked_handler(+ payload: WildValue,+ branches: str | None,+ include_title: str | None,+) -> list[dict[str, str]]:+ repo_name = payload["repository"]["origin"]["name"].tame(check_string)+ topic_name = BITBUCKET_TOPIC_TEMPLATE.format(repository_name=repo_name)+ body = BITBUCKET_FORK_BODY.format(+ display_name=payload["actor"]["displayName"].tame(check_string),+ username=get_user_name(payload),+ fork_name=payload["repository"]["name"].tame(check_string),+ fork_url=payload["repository"]["links"]["self"][0]["href"].tame(check_string),+ )+ return [{"topic": topic_name, "body": body}]+++def repo_modified_handler(+ payload: WildValue,+ branches: str | None,+ include_title: str | None,+) -> list[dict[str, str]]:+ topic_name_new = BITBUCKET_TOPIC_TEMPLATE.format(+ repository_name=payload["new"]["name"].tame(check_string)+ )+ new_name = payload["new"]["name"].tame(check_string)+ body = BITBUCKET_REPO_UPDATED_CHANGED.format(+ actor=get_user_name(payload),+ change="name",+ repo_name=payload["old"]["name"].tame(check_string),+ old=payload["old"]["name"].tame(check_string),+ new=new_name,+ ) # As of writing this, the only change we'd be notified about is a name change.+ punctuation = "." if new_name[-1] not in string.punctuation else ""+ body = f"{body}{punctuation}"+ return [{"topic": topic_name_new, "body": body}]+++def repo_push_branch_data(payload: WildValue, change: WildValue) -> dict[str, str]:+ event_type = change["type"].tame(check_string)+ repo_name = payload["repository"]["name"].tame(check_string)+ user_name = get_user_name(payload)+ branch_name = change["ref"]["displayId"].tame(check_string)+ branch_head = change["toHash"].tame(check_string)++ if event_type == "ADD":+ body = get_create_branch_event_message(+ user_name=user_name,+ url=None,+ branch_name=branch_name,+ )+ elif event_type == "UPDATE":+ body = BRANCH_UPDATED_MESSAGE_TEMPLATE.format(+ user_name=user_name,+ branch_name=branch_name,+ head=branch_head,+ )+ elif event_type == "DELETE":+ body = get_remove_branch_event_message(user_name, branch_name)+ else:+ message = "{}.{}".format(payload["eventKey"].tame(check_string), event_type) # nocoverage+ raise UnsupportedWebhookEventTypeError(message)++ topic_name = TOPIC_WITH_BRANCH_TEMPLATE.format(repo=repo_name, branch=branch_name)+ return {"topic": topic_name, "body": body}+++def repo_push_tag_data(payload: WildValue, change: WildValue) -> dict[str, str]:+ event_type = change["type"].tame(check_string)+ repo_name = payload["repository"]["name"].tame(check_string)+ tag_name = change["ref"]["displayId"].tame(check_string)++ if event_type == "ADD":+ action = "pushed"+ elif event_type == "DELETE":+ action = "removed"+ else:+ message = "{}.{}".format(payload["eventKey"].tame(check_string), event_type) # nocoverage+ raise UnsupportedWebhookEventTypeError(message)++ topic_name = BITBUCKET_TOPIC_TEMPLATE.format(repository_name=repo_name)+ body = get_push_tag_event_message(get_user_name(payload), tag_name, action=action)+ return {"topic": topic_name, "body": body}+++def repo_push_handler(+ payload: WildValue,+ branches: str | None,+ include_title: str | None,+) -> list[dict[str, str]]:+ data = []+ for change in payload["changes"]:+ event_target_type = change["ref"]["type"].tame(check_string)+ if event_target_type == "BRANCH":+ branch = change["ref"]["displayId"].tame(check_string)+ if not is_branch_name_notifiable(branch, branches):+ continue+ data.append(repo_push_branch_data(payload, change))+ elif event_target_type == "TAG":+ data.append(repo_push_tag_data(payload, change))+ else:+ message = "{}.{}".format(+ payload["eventKey"].tame(check_string), event_target_type+ ) # nocoverage+ raise UnsupportedWebhookEventTypeError(message)+ return data+++def get_assignees_string(pr: WildValue) -> str | None:+ reviewers = []+ for reviewer in pr["reviewers"]:+ name = reviewer["user"]["name"].tame(check_string)+ link = reviewer["user"]["links"]["self"][0]["href"].tame(check_string)+ reviewers.append(f"[{name}]({link})")+ if len(reviewers) == 0:+ assignees = None+ elif len(reviewers) == 1:+ assignees = reviewers[0]+ else:+ assignees = ", ".join(reviewers[:-1]) + " and " + reviewers[-1]+ return assignees+++def get_pr_topic(repo: str, type: str, id: int, title: str) -> str:+ return TOPIC_WITH_PR_OR_ISSUE_INFO_TEMPLATE.format(repo=repo, type=type, id=id, title=title)+++def get_simple_pr_body(payload: WildValue, action: str, include_title: str | None) -> str:+ pr = payload["pullRequest"]+ return get_pull_request_event_message(+ user_name=get_user_name(payload),+ action=action,+ url=pr["links"]["self"][0]["href"].tame(check_string),+ number=pr["id"].tame(check_int),+ title=pr["title"].tame(check_string) if include_title else None,+ )+++def get_pr_opened_or_modified_body(+ payload: WildValue, action: str, include_title: str | None+) -> str:+ pr = payload["pullRequest"]+ description = pr.get("description").tame(check_none_or(check_string))+ target_branch = None+ base_branch = None+ if action == "opened":+ target_branch = pr["fromRef"]["displayId"].tame(check_string)+ base_branch = pr["toRef"]["displayId"].tame(check_string)+ reviewers_string = get_assignees_string(pr)++ return get_pull_request_event_message(+ user_name=get_user_name(payload),+ action=action,+ url=pr["links"]["self"][0]["href"].tame(check_string),+ number=pr["id"].tame(check_int),+ target_branch=target_branch,+ base_branch=base_branch,+ message=description,+ reviewer=reviewers_string or None,+ title=pr["title"].tame(check_string) if include_title else None,+ )+++def get_pr_merged_body(payload: WildValue, action: str, include_title: str | None) -> str:+ pr = payload["pullRequest"]+ return get_pull_request_event_message(+ user_name=get_user_name(payload),+ action=action,+ url=pr["links"]["self"][0]["href"].tame(check_string),+ number=pr["id"].tame(check_int),+ target_branch=pr["fromRef"]["displayId"].tame(check_string),+ base_branch=pr["toRef"]["displayId"].tame(check_string),+ title=pr["title"].tame(check_string) if include_title else None,+ )+++def get_pr_needs_work_body(payload: WildValue, include_title: str | None) -> str:+ pr = payload["pullRequest"]+ if not include_title:+ return PULL_REQUEST_MARKED_AS_NEEDS_WORK_TEMPLATE.format(+ user_name=get_user_name(payload),+ number=pr["id"].tame(check_int),+ url=pr["links"]["self"][0]["href"].tame(check_string),+ )+ return PULL_REQUEST_MARKED_AS_NEEDS_WORK_TEMPLATE_WITH_TITLE.format(+ user_name=get_user_name(payload),+ number=pr["id"].tame(check_int),+ url=pr["links"]["self"][0]["href"].tame(check_string),+ title=pr["title"].tame(check_string),+ )+++def get_pr_reassigned_body(payload: WildValue, include_title: str | None) -> str:+ pr = payload["pullRequest"]+ assignees_string = get_assignees_string(pr)+ if not assignees_string:+ if not include_title:+ return PULL_REQUEST_REASSIGNED_TO_NONE_TEMPLATE.format(+ user_name=get_user_name(payload),+ number=pr["id"].tame(check_int),+ url=pr["links"]["self"][0]["href"].tame(check_string),+ )+ punctuation = "." if pr["title"].tame(check_string)[-1] not in string.punctuation else ""+ message = PULL_REQUEST_REASSIGNED_TO_NONE_TEMPLATE_WITH_TITLE.format(+ user_name=get_user_name(payload),+ number=pr["id"].tame(check_int),+ url=pr["links"]["self"][0]["href"].tame(check_string),+ title=pr["title"].tame(check_string),+ )+ message = f"{message}{punctuation}"+ return message+ if not include_title:+ return PULL_REQUEST_REASSIGNED_TEMPLATE.format(+ user_name=get_user_name(payload),+ number=pr["id"].tame(check_int),+ url=pr["links"]["self"][0]["href"].tame(check_string),+ assignees=assignees_string,+ )+ return PULL_REQUEST_REASSIGNED_TEMPLATE_WITH_TITLE.format(+ user_name=get_user_name(payload),+ number=pr["id"].tame(check_int),+ url=pr["links"]["self"][0]["href"].tame(check_string),+ assignees=assignees_string,+ title=pr["title"].tame(check_string),+ )+++def pr_handler(+ action: str,+ payload: WildValue,+ branches: str | None,+ include_title: str | None,+) -> list[dict[str, str]]:+ pr = payload["pullRequest"]+ topic_name = get_pr_topic(+ pr["toRef"]["repository"]["name"].tame(check_string),+ type="PR",+ id=pr["id"].tame(check_int),+ title=pr["title"].tame(check_string),+ )+ if action in ["opened", "modified"]:+ body = get_pr_opened_or_modified_body(payload, action, include_title)+ elif action == "merged":+ body = get_pr_merged_body(payload, action, include_title)+ elif action == "needs_work":+ body = get_pr_needs_work_body(payload, include_title)+ elif action == "reviewers_updated":+ body = get_pr_reassigned_body(payload, include_title)+ else:+ body = get_simple_pr_body(payload, action, include_title)++ return [{"topic": topic_name, "body": body}]+++def pr_comment_handler(+ action: str,+ payload: WildValue,+ branches: str | None,+ include_title: str | None,+) -> list[dict[str, str]]:+ pr = payload["pullRequest"]+ topic_name = get_pr_topic(+ pr["toRef"]["repository"]["name"].tame(check_string),+ type="PR",+ id=pr["id"].tame(check_int),+ title=pr["title"].tame(check_string),+ )+ message = payload["comment"]["text"].tame(check_string)+ if action == "deleted their comment on":+ message = f"~~{message}~~"+ body = get_pull_request_event_message(+ user_name=get_user_name(payload),+ action=action,+ url=pr["links"]["self"][0]["href"].tame(check_string),+ number=pr["id"].tame(check_int),+ message=message,+ title=pr["title"].tame(check_string) if include_title else None,+ )++ return [{"topic": topic_name, "body": body}]+++class EventHandler(Protocol):+ def __call__(+ self, payload: WildValue, branches: str | None, include_title: str | None+ ) -> list[dict[str, str]]: ...+++EVENT_HANDLER_MAP: dict[str, EventHandler] = {+ "diagnostics:ping": ping_handler,+ "repo:comment:added": partial(repo_comment_handler, "commented"),+ "repo:comment:edited": partial(repo_comment_handler, "edited their comment"),+ "repo:comment:deleted": partial(repo_comment_handler, "deleted their comment"),+ "repo:forked": repo_forked_handler,+ "repo:modified": repo_modified_handler,+ "repo:refs_changed": repo_push_handler,+ "pr:comment:added": partial(pr_comment_handler, "commented on"),+ "pr:comment:edited": partial(pr_comment_handler, "edited their comment on"),+ "pr:comment:deleted": partial(pr_comment_handler, "deleted their comment on"),+ "pr:declined": partial(pr_handler, "declined"),+ "pr:deleted": partial(pr_handler, "deleted"),+ "pr:merged": partial(pr_handler, "merged"),+ "pr:modified": partial(pr_handler, "modified"),+ "pr:opened": partial(pr_handler, "opened"),+ "pr:reviewer:approved": partial(pr_handler, "approved"),+ "pr:reviewer:needs_work": partial(pr_handler, "needs_work"),+ "pr:reviewer:updated": partial(pr_handler, "reviewers_updated"),+ "pr:reviewer:unapproved": partial(pr_handler, "unapproved"),+}++ALL_EVENT_TYPES = list(EVENT_HANDLER_MAP.keys())+++@webhook_view("Bitbucket3", all_event_types=ALL_EVENT_TYPES)+@typed_endpoint+def api_bitbucketdatacenter_webhook(+ request: HttpRequest,+ user_profile: UserProfile,+ *,+ payload: JsonBodyPayload[WildValue],+ branches: str | None = None,+ user_specified_topic: OptionalUserSpecifiedTopicStr = None,+) -> HttpResponse:+ eventkey: str | None+ if "eventKey" in payload:+ eventkey = payload["eventKey"].tame(check_string)+ else:+ eventkey = get_event_header(request, "X-Event-Key", "BitBucket")+ handler = EVENT_HANDLER_MAP.get(eventkey)+ if handler is None:+ raise UnsupportedWebhookEventTypeError(eventkey)++ data = handler(payload, branches=branches, include_title=user_specified_topic)+ for element in data:+ check_send_webhook_message(+ request,+ user_profile,+ element["topic"],+ element["body"],+ eventkey,+ unquote_url_parameters=True,+ )++ return json_success(request)