api: Add bot name to outgoing webhook payload.

Fixes: #12282
This commit is contained in:
PIG208 2021-04-07 03:24:57 +08:00 committed by Tim Abbott
parent e51344ab2d
commit c6dfe7bf40
3 changed files with 9 additions and 2 deletions

View File

@ -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"],
}

View File

@ -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:

View File

@ -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)