mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
Clean up URLs sent by outgoing webhooks.
When you send a message to a bot that wants to talk via an outgoing webhook, and there's an error (e.g. server is down), we send a message to the bot's owner that links to the message that triggered the error. The code to produce those links was out of date. Now we move the important code to the `url_encoding.py` library and fix the PM links to use the more modern style (user_ids instead of emails). We also replace "subject" with "topic" in the stream urls.
This commit is contained in:
@@ -78,7 +78,7 @@ class DoRestCallTests(ZulipTestCase):
|
||||
do_rest_call('', None, self.mock_event, service_handler)
|
||||
bot_owner_notification = self.get_last_message()
|
||||
self.assertEqual(bot_owner_notification.content,
|
||||
'''[A message](http://zulip.testserver/#narrow/stream/999-Verona/subject/Foo/near/) triggered an outgoing webhook.
|
||||
'''[A message](http://zulip.testserver/#narrow/stream/999-Verona/topic/Foo/near/) triggered an outgoing webhook.
|
||||
The webhook got a response with status code *500*.''')
|
||||
self.assertEqual(bot_owner_notification.recipient_id, self.bot_user.bot_owner.id)
|
||||
self.mock_event['failed_tries'] = 0
|
||||
@@ -91,7 +91,7 @@ The webhook got a response with status code *500*.''')
|
||||
bot_owner_notification = self.get_last_message()
|
||||
self.assertTrue(mock_fail_with_message.called)
|
||||
self.assertEqual(bot_owner_notification.content,
|
||||
'''[A message](http://zulip.testserver/#narrow/stream/999-Verona/subject/Foo/near/) triggered an outgoing webhook.
|
||||
'''[A message](http://zulip.testserver/#narrow/stream/999-Verona/topic/Foo/near/) triggered an outgoing webhook.
|
||||
The webhook got a response with status code *400*.''')
|
||||
self.assertEqual(bot_owner_notification.recipient_id, self.bot_user.bot_owner.id)
|
||||
|
||||
@@ -117,7 +117,7 @@ The webhook got a response with status code *400*.''')
|
||||
bot_owner_notification = self.get_last_message()
|
||||
self.assertTrue(mock_fail_with_message.called)
|
||||
self.assertEqual(bot_owner_notification.content,
|
||||
'''[A message](http://zulip.testserver/#narrow/stream/999-Verona/subject/Foo/near/) triggered an outgoing webhook.
|
||||
'''[A message](http://zulip.testserver/#narrow/stream/999-Verona/topic/Foo/near/) 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 :(
|
||||
|
||||
Reference in New Issue
Block a user