Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
jira: Use sentence format for issue created webhook messages.
0xthedance62cccc7f42a3
diff --git a/static/images/integrations/jira/001.png b/static/images/integrations/jira/001.pngindex a28fabff890..5c06ee1a700 100644Binary files a/static/images/integrations/jira/001.png and b/static/images/integrations/jira/001.png differdiff --git a/zerver/webhooks/jira/fixtures/issue_created_with_assignee.json b/zerver/webhooks/jira/fixtures/issue_created_with_assignee.jsonindex def35b332a1..9bc84bf930e 100644--- a/zerver/webhooks/jira/fixtures/issue_created_with_assignee.json+++ b/zerver/webhooks/jira/fixtures/issue_created_with_assignee.json@@ -2,17 +2,17 @@"webhookEvent": "jira:issue_created","issue_event_type_name":"issue_created","user": {- "self": "https://zulipp.atlassian.net/rest/api/2/user?username=leo",- "name": "leo",+ "self": "https://zulipp.atlassian.net/rest/api/2/user?username=bwilliams",+ "name": "bwilliams","accountId": "99:e2f12cf6-839d-4ea2-ae07-e1a59cb009c8",- "emailAddress": "[email protected]",+ "emailAddress": "[email protected]","avatarUrls": {"16x16": "https://zulipp.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122","24x24": "https://zulipp.atlassian.net/secure/useravatar?size=small&avatarId=10122","32x32": "https://zulipp.atlassian.net/secure/useravatar?size=medium&avatarId=10122","48x48": "https://zulipp.atlassian.net/secure/useravatar?avatarId=10122"},- "displayName": "Leonardo Franchi [Administrator]",+ "displayName": "Bo Williams","active": true},"issue": {@@ -36,17 +36,17 @@},"timespent": null,"reporter": {- "self": "https://zulipp.atlassian.net/rest/api/2/user?username=leo",- "name": "leo",+ "self": "https://zulipp.atlassian.net/rest/api/2/user?username=bwilliams",+ "name": "bwilliams","accountId": "99:e2f12cf6-839d-4ea2-ae07-e1a59cb009c8",- "emailAddress": "[email protected]",+ "emailAddress": "[email protected]","avatarUrls": {"16x16": "https://zulipp.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122","24x24": "https://zulipp.atlassian.net/secure/useravatar?size=small&avatarId=10122","32x32": "https://zulipp.atlassian.net/secure/useravatar?size=medium&avatarId=10122","48x48": "https://zulipp.atlassian.net/secure/useravatar?avatarId=10122"},- "displayName": "Leonardo Franchi [Administrator]",+ "displayName": "Bo Williams","active": true},"created": "2013-09-06T11:20:24.101-0400",@@ -134,17 +134,17 @@"worklogs": []},"assignee": {- "self": "https://zulipp.atlassian.net/rest/api/2/user?username=leo",- "name": "leo",- "accountId": "99:e2f12cf6-839d-4ea2-ae07-e1a59cb009c8",- "emailAddress": "[email protected]",+ "self": "https://zulipp.atlassian.net/rest/api/2/user?username=klin",+ "name": "klin",+ "accountId": "99:a5b6c7d8-9012-4e3f-8b7a-1c2d3e4f5a6b",+ "emailAddress": "[email protected]","avatarUrls": {"16x16": "https://zulipp.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122","24x24": "https://zulipp.atlassian.net/secure/useravatar?size=small&avatarId=10122","32x32": "https://zulipp.atlassian.net/secure/useravatar?size=medium&avatarId=10122","48x48": "https://zulipp.atlassian.net/secure/useravatar?avatarId=10122"},- "displayName": "Leonardo Franchi [Administrator]",+ "displayName": "Kevin Lin","active": true},"attachment": [],diff --git a/zerver/webhooks/jira/tests.py b/zerver/webhooks/jira/tests.pyindex 3b46f4f0dbb..009f527d773 100644--- a/zerver/webhooks/jira/tests.py+++ b/zerver/webhooks/jira/tests.py@@ -16,12 +16,7 @@ class JiraHookTests(WebhookTestCase):self.get_body("issue_created"),content_type="application/json",)- expected_content = """-@_**Othello, the Moor of Venice|12** created [BUG-15: New bug with hook](http://lfranchi.com:8080/browse/BUG-15):--* **Priority**: Major-* **Assignee**: no one-""".strip()+ expected_content = "@_**Othello, the Moor of Venice|12** created [BUG-15: New bug with hook](http://lfranchi.com:8080/browse/BUG-15) with major priority."self.assert_channel_message(message=msg,channel_name="jira_custom",@@ -31,12 +26,7 @@ class JiraHookTests(WebhookTestCase):def test_created(self) -> None:expected_topic_name = "BUG-15: New bug with hook"- expected_message = """-@_**Othello, the Moor of Venice|12** created [BUG-15: New bug with hook](http://lfranchi.com:8080/browse/BUG-15):--* **Priority**: Major-* **Assignee**: no one-""".strip()+ expected_message = "@_**Othello, the Moor of Venice|12** created [BUG-15: New bug with hook](http://lfranchi.com:8080/browse/BUG-15) with major priority."self.check_webhook("issue_created", expected_topic_name, expected_message)def test_ignored_events(self) -> None:@@ -61,22 +51,12 @@ class JiraHookTests(WebhookTestCase):def test_created_with_unicode(self) -> None:expected_topic_name = "BUG-15: New bug with à hook"- expected_message = """-@_**Othello, the Moor of Venice|12** created [BUG-15: New bug with à hook](http://lfranchi.com:8080/browse/BUG-15):--* **Priority**: Major-* **Assignee**: no one-""".strip()+ expected_message = "@_**Othello, the Moor of Venice|12** created [BUG-15: New bug with à hook](http://lfranchi.com:8080/browse/BUG-15) with major priority."self.check_webhook("issue_created_with_unicode", expected_topic_name, expected_message)def test_created_assignee(self) -> None:expected_topic_name = "TEST-4: Test Created Assignee"- expected_message = """-Leonardo Franchi [Administrator] created [TEST-4: Test Created Assignee](https://zulipp.atlassian.net/browse/TEST-4):--* **Priority**: Major-* **Assignee**: Leonardo Franchi [Administrator]-""".strip()+ expected_message = "Bo Williams created [TEST-4: Test Created Assignee](https://zulipp.atlassian.net/browse/TEST-4) with major priority (assigned to Kevin Lin)."self.check_webhook("issue_created_with_assignee", expected_topic_name, expected_message)def test_deleted(self) -> None:@@ -144,12 +124,7 @@ Leonardo Franchi [Administrator] created [TEST-4: Test Created Assignee](https:/def test_created_silent_mention_by_email_fallback(self) -> None:othello = self.example_user("othello")expected_topic_name = "BUG-15: New bug with hook"- expected_message = f"""-@_**{othello.full_name}|{othello.id}** created [BUG-15: New bug with hook](http://lfranchi.com:8080/browse/BUG-15):--* **Priority**: Major-* **Assignee**: no one-""".strip()+ expected_message = f"@_**{othello.full_name}|{othello.id}** created [BUG-15: New bug with hook](http://lfranchi.com:8080/browse/BUG-15) with major priority."self.check_webhook("issue_created", expected_topic_name, expected_message)def test_comment_created_silent_mention_atlassian_account_id(self) -> None:diff --git a/zerver/webhooks/jira/view.py b/zerver/webhooks/jira/view.pyindex 8a10e8fda25..63ef6f63840 100644--- a/zerver/webhooks/jira/view.py+++ b/zerver/webhooks/jira/view.py@@ -255,24 +255,20 @@ def handle_updated_issue_event(payload: WildValue, user_profile: UserProfile) ->def handle_created_issue_event(payload: WildValue, user_profile: UserProfile) -> str:- template = """-{author} created {issue_string}:--* **Priority**: {priority}-* **Assignee**: {assignee}-""".strip()+ priority = get_in(payload, ["issue", "fields", "priority", "name"]).tame(check_string).lower()assignee_payload = get_in(payload, ["issue", "fields", "assignee"])if assignee_payload.value and isinstance(assignee_payload.value, dict):- assignee = get_user_mention(user_profile.realm, assignee_payload)+ assignee_blurb = f" (assigned to {get_user_mention(user_profile.realm, assignee_payload)})"else:- assignee = "no one"+ assignee_blurb = ""+ template = "{author} created {issue_string} with {priority} priority{assignee_blurb}."return template.format(author=get_issue_author(payload, user_profile.realm),issue_string=get_issue_string(payload, with_title=True),- priority=get_in(payload, ["issue", "fields", "priority", "name"]).tame(check_string),- assignee=assignee,+ priority=priority,+ assignee_blurb=assignee_blurb,)