mirror of https://github.com/zulip/zulip.git
webhooks/mention: Use proper message formatting.
This commit is contained in:
parent
1948924cdb
commit
120937a1f4
|
@ -9,12 +9,14 @@ class MentionHookTests(WebhookTestCase):
|
|||
|
||||
def test_mention_webfeed(self) -> None:
|
||||
expected_topic = u"news"
|
||||
expected_message = (u"**[Historical Sexual Abuse (Football): 29 Nov 2016: House of Commons debates - TheyWorkForYou]"
|
||||
u"(https://www.theyworkforyou.com/debates/?id=2016-11-29b.1398.7&p=24887)**:\n"
|
||||
u"\u2026 Culture, Media and Sport\nNothing is more important than keeping children safe."
|
||||
u" Child sex abuse is an exceptionally vile crime, and all of Government take it very seriously indeed,"
|
||||
u" as I know this House does.\nChildren up and down the country are \u2026"
|
||||
)
|
||||
expected_message = """
|
||||
**[Historical Sexual Abuse (Football): 29 Nov 2016: House of Commons debates - TheyWorkForYou](https://www.theyworkforyou.com/debates/?id=2016-11-29b.1398.7&p=24887)**:
|
||||
|
||||
``` quote
|
||||
\u2026 Culture, Media and Sport\nNothing is more important than keeping children safe. Child sex abuse is an exceptionally vile crime, and all of Government take it very seriously indeed, as I know this House does.
|
||||
Children up and down the country are \u2026
|
||||
```
|
||||
""".strip()
|
||||
|
||||
# use fixture named mention_webfeeds
|
||||
self.send_and_test_stream_message('webfeeds', expected_topic, expected_message,
|
||||
|
|
|
@ -19,7 +19,15 @@ def api_mention_webhook(
|
|||
source_url = payload["url"]
|
||||
description = payload["description"]
|
||||
# construct the body of the message
|
||||
body = '**[%s](%s)**:\n%s' % (title, source_url, description)
|
||||
template = """
|
||||
**[{title}]({url})**:
|
||||
|
||||
``` quote
|
||||
{description}
|
||||
```
|
||||
""".strip()
|
||||
body = template.format(title=title, url=source_url,
|
||||
description=description)
|
||||
topic = 'news'
|
||||
|
||||
# send the message
|
||||
|
|
Loading…
Reference in New Issue