Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

outgoing_webhook: Add bot name when a outgoing_webhook is triggered.

Siddharth Asthana5ec0860a2f64
diff --git a/zerver/lib/outgoing_webhook.py b/zerver/lib/outgoing_webhook.py
index a5fecbb90c7..b4a6be1fcd4 100644
--- a/zerver/lib/outgoing_webhook.py
+++ b/zerver/lib/outgoing_webhook.py
@@ -236,10 +236,11 @@ def notify_bot_owner(
) -> None:
message_url = get_message_url(event)
bot_id = event["user_profile_id"]
- bot_owner = get_user_profile_by_id(bot_id).bot_owner
+ bot = get_user_profile_by_id(bot_id)
+ bot_owner = bot.bot_owner
assert bot_owner is not None
- notification_message = f"[A message]({message_url}) triggered an outgoing webhook."
+ notification_message = f"[A message]({message_url}) to your bot @_**{bot.full_name}** triggered an outgoing webhook."
if failure_message:
notification_message += "\n" + failure_message
if status_code:
diff --git a/zerver/tests/test_outgoing_webhook_system.py b/zerver/tests/test_outgoing_webhook_system.py
index 01b178085c0..4705b79fb82 100644
--- a/zerver/tests/test_outgoing_webhook_system.py
+++ b/zerver/tests/test_outgoing_webhook_system.py
@@ -99,7 +99,7 @@ class DoRestCallTests(ZulipTestCase):
bot_owner_notification = self.get_last_message()
self.assertEqual(
bot_owner_notification.content,
- """[A message](http://zulip.testserver/#narrow/stream/999-Verona/topic/Foo/near/) triggered an outgoing webhook.
+ """[A message](http://zulip.testserver/#narrow/stream/999-Verona/topic/Foo/near/) to your bot @_**Outgoing Webhook** triggered an outgoing webhook.
The webhook got a response with status code *500*.""",
)
@@ -131,7 +131,7 @@ The webhook got a response with status code *500*.""",
bot_owner_notification = self.get_last_message()
self.assertEqual(
bot_owner_notification.content,
- """[A message](http://zulip.testserver/#narrow/stream/999-Verona/topic/Foo/near/) triggered an outgoing webhook.
+ """[A message](http://zulip.testserver/#narrow/stream/999-Verona/topic/Foo/near/) to your bot @_**Outgoing Webhook** triggered an outgoing webhook.
The webhook got a response with status code *400*.""",
)
@@ -215,7 +215,7 @@ The webhook got a response with status code *400*.""",
bot_owner_notification = self.get_last_message()
self.assertEqual(
bot_owner_notification.content,
- """[A message](http://zulip.testserver/#narrow/stream/999-Verona/topic/Foo/near/) triggered an outgoing webhook.
+ """[A message](http://zulip.testserver/#narrow/stream/999-Verona/topic/Foo/near/) to your bot @_**Outgoing Webhook** triggered an outgoing webhook.
When trying to send a request to the webhook service, an exception of type RequestException occurred:
```
I'm a generic exception :(