Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
webhook/github: Add emoji support for deployment status events.
Pritesh Shetty2c24c33c237c
diff --git a/zerver/webhooks/github/tests.py b/zerver/webhooks/github/tests.pyindex 6dd8c013481..66f697f5bcc 100644--- a/zerver/webhooks/github/tests.py+++ b/zerver/webhooks/github/tests.py@@ -145,22 +145,22 @@ class GitHubWebhookTest(WebhookTestCase):self.check_webhook("deployment", TOPIC_DEPLOYMENT, expected_message)def test_deployment_status_success_msg(self) -> None:- expected_message = "Deployment changed status to success."+ expected_message = ":check: Deployment changed status to success."self.check_webhook("deployment_status__success", TOPIC_DEPLOYMENT, expected_message)def test_deployment_status_pending_msg(self) -> None:expected_topic_name = "test-repo / Deployment on production"- expected_message = "Deployment changed status to pending."+ expected_message = ":time_ticking: Deployment changed status to pending."self.check_webhook("deployment_status__pending", expected_topic_name, expected_message)def test_deployment_status_error_msg(self) -> None:expected_topic_name = "test-repo / Deployment on production"- expected_message = "Deployment changed status to error."+ expected_message = ":rotating_light: Deployment changed status to error."self.check_webhook("deployment_status__error", expected_topic_name, expected_message)def test_deployment_status_failure_msg(self) -> None:expected_topic_name = "test-repo / Deployment on production"- expected_message = "Deployment changed status to failure."+ expected_message = ":warning: Deployment changed status to failure."self.check_webhook("deployment_status__failure", expected_topic_name, expected_message)def test_fork_msg(self) -> None:diff --git a/zerver/webhooks/github/view.py b/zerver/webhooks/github/view.pyindex ac0c6f990d7..80c4775d17d 100644--- a/zerver/webhooks/github/view.py+++ b/zerver/webhooks/github/view.py@@ -83,6 +83,13 @@ PR_CLOSE_ACTION_EMOJI = {"closed without merge": ":cross_mark:",}+DEPLOYMENT_STATUS_EMOJI = {+ "success": ":check:",+ "failure": ":warning:",+ "error": ":rotating_light:",+ "pending": ":time_ticking:",+}+class Helper:def __init__(@@ -286,9 +293,9 @@ def get_deployment_body(helper: Helper) -> str:def get_change_deployment_status_body(helper: Helper) -> str:payload = helper.payload- return "Deployment changed status to {}.".format(- payload["deployment_status"]["state"].tame(check_string),- )+ state = payload["deployment_status"]["state"].tame(check_string)+ emoji = DEPLOYMENT_STATUS_EMOJI.get(state, "") if helper.include_emoji_indicators else ""+ return f"{emoji} Deployment changed status to {state}.".strip()def get_create_or_delete_body(action: str, helper: Helper) -> str: