From c6dfe7bf40ee1351e4d098612b2fe99052529401 Mon Sep 17 00:00:00 2001 From: PIG208 <359101898@qq.com> Date: Wed, 7 Apr 2021 03:24:57 +0800 Subject: [PATCH] api: Add bot name to outgoing webhook payload. Fixes: #12282 --- zerver/lib/outgoing_webhook.py | 1 + zerver/openapi/zulip.yaml | 5 +++++ zerver/tests/test_outgoing_webhook_interfaces.py | 5 +++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/zerver/lib/outgoing_webhook.py b/zerver/lib/outgoing_webhook.py index 19642fa5aa..13aaf37d0c 100644 --- a/zerver/lib/outgoing_webhook.py +++ b/zerver/lib/outgoing_webhook.py @@ -69,6 +69,7 @@ class GenericOutgoingWebhookService(OutgoingWebhookServiceInterface): "data": event["command"], "message": message_dict, "bot_email": self.user_profile.email, + "bot_full_name": self.user_profile.full_name, "token": self.token, "trigger": event["trigger"], } diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml index 8a4a734097..83cff00dfa 100644 --- a/zerver/openapi/zulip.yaml +++ b/zerver/openapi/zulip.yaml @@ -9302,6 +9302,10 @@ paths: type: string description: | Email of the bot user. + bot_full_name: + type: string + description: | + The full name of the bot user. data: type: string description: | @@ -9376,6 +9380,7 @@ paths: "sender_realm_str": "zulip", }, "bot_email": "outgoing-bot@localhost", + "bot_full_name": "Outgoing webhook test", } /calls/bigbluebutton/create: diff --git a/zerver/tests/test_outgoing_webhook_interfaces.py b/zerver/tests/test_outgoing_webhook_interfaces.py index bb4f1318ae..a7780d5e15 100644 --- a/zerver/tests/test_outgoing_webhook_interfaces.py +++ b/zerver/tests/test_outgoing_webhook_interfaces.py @@ -18,10 +18,10 @@ class TestGenericOutgoingWebhookService(ZulipTestCase): def setUp(self) -> None: super().setUp() - bot_user = get_user("outgoing-webhook@zulip.com", get_realm("zulip")) + self.bot_user = get_user("outgoing-webhook@zulip.com", get_realm("zulip")) service_class = get_service_interface_class("whatever") # GenericOutgoingWebhookService self.handler = service_class( - service_name="test-service", token="abcdef", user_profile=bot_user + service_name="test-service", token="abcdef", user_profile=self.bot_user ) def test_process_success_response(self) -> None: @@ -113,6 +113,7 @@ class TestGenericOutgoingWebhookService(ZulipTestCase): request_data = session.post.call_args[1]["json"] validate_against_openapi_schema(request_data, "/zulip-outgoing-webhook", "post", "200") + self.assertEqual(request_data["bot_full_name"], self.bot_user.full_name) self.assertEqual(request_data["data"], "@**test**") self.assertEqual(request_data["token"], "abcdef") self.assertEqual(request_data["message"], expected_message_data)