Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
webhooks: Rephrase message for Issue Assigned and Unassigned Events.
sbansal199977ae3176cac2
diff --git a/zerver/webhooks/github/tests.py b/zerver/webhooks/github/tests.pyindex 2be5beea4db..8172de9c044 100644--- a/zerver/webhooks/github/tests.py+++ b/zerver/webhooks/github/tests.py@@ -143,25 +143,25 @@ class GitHubWebhookTest(WebhookTestCase):self.check_webhook("issues", expected_topic, expected_message)def test_issue_assigned(self) -> None:- expected_message = "sbansal1999 assigned [issue #7](https://github.com/sbansal1999/testing-gh/issues/7) (assigned to sbansal1999)."+ expected_message = "sbansal1999 assigned [issue #7](https://github.com/sbansal1999/testing-gh/issues/7) to sbansal1999."expected_topic = "testing-gh / issue #7 Sample Issue testing something"self.check_webhook("issues__assigned", expected_topic, expected_message)def test_issue_assigned_with_custom_topic_in_url(self) -> None:self.url = self.build_webhook_url(topic="notifications")expected_topic = "notifications"- expected_message = "sbansal1999 assigned [issue #7 Sample Issue testing something](https://github.com/sbansal1999/testing-gh/issues/7) (assigned to sbansal1999)."+ expected_message = "sbansal1999 assigned [issue #7 Sample Issue testing something](https://github.com/sbansal1999/testing-gh/issues/7) to sbansal1999."self.check_webhook("issues__assigned", expected_topic, expected_message)def test_issue_unassigned(self) -> None:- expected_message = "sbansal1999 unassigned [issue #9](https://github.com/sbansal1999/testing-gh/issues/9) (assigned to sbansal1999)."+ expected_message = "sbansal1999 unassigned sbansal1999 from [issue #9](https://github.com/sbansal1999/testing-gh/issues/9)."expected_topic = "testing-gh / issue #9 idk man"self.check_webhook("issues__unassigned", expected_topic, expected_message)def test_issue_unassigned_with_custom_topic_in_url(self) -> None:self.url = self.build_webhook_url(topic="notifications")expected_topic = "notifications"- expected_message = "sbansal1999 unassigned [issue #9 idk man](https://github.com/sbansal1999/testing-gh/issues/9) (assigned to sbansal1999)."+ expected_message = "sbansal1999 unassigned sbansal1999 from [issue #9 idk man](https://github.com/sbansal1999/testing-gh/issues/9)."self.check_webhook("issues__unassigned", expected_topic, expected_message)def test_membership_msg(self) -> None:diff --git a/zerver/webhooks/github/view.py b/zerver/webhooks/github/view.pyindex 48ef43939c5..2365adffcb7 100644--- a/zerver/webhooks/github/view.py+++ b/zerver/webhooks/github/view.py@@ -160,7 +160,7 @@ def get_issue_body(helper: Helper) -> str:action = payload["action"].tame(check_string)issue = payload["issue"]has_assignee = "assignee" in payload- return get_issue_event_message(+ base_message = get_issue_event_message(user_name=get_sender_name(payload),action=action,url=issue["html_url"].tame(check_string),@@ -168,10 +168,18 @@ def get_issue_body(helper: Helper) -> str:message=Noneif action in ("assigned", "unassigned")else issue["body"].tame(check_none_or(check_string)),- assignee=payload["assignee"]["login"].tame(check_string) if has_assignee else None,title=issue["title"].tame(check_string) if include_title else None,)+ if has_assignee:+ stringified_assignee = payload["assignee"]["login"].tame(check_string)+ if action == "assigned":+ return f"{base_message[:-1]} to {stringified_assignee}."+ elif action == "unassigned":+ return base_message.replace("unassigned", f"unassigned {stringified_assignee} from")++ return base_message+def get_issue_comment_body(helper: Helper) -> str:payload = helper.payload