mirror of https://github.com/zulip/zulip.git
webhooks/wordpress: Improve message formatting and punctuation.
This commit is contained in:
parent
0a0df3bc58
commit
21cdb6decc
|
@ -9,7 +9,7 @@ class WordPressHookTests(WebhookTestCase):
|
|||
def test_publish_post(self) -> None:
|
||||
|
||||
expected_topic = u"WordPress Post"
|
||||
expected_message = u"New post published.\n[New Blog Post](http://example.com\n)"
|
||||
expected_message = u"New post published:\n* [New Blog Post](http://example.com\n)"
|
||||
|
||||
self.send_and_test_stream_message('publish_post', expected_topic, expected_message,
|
||||
content_type="application/x-www-form-urlencoded")
|
||||
|
@ -17,7 +17,7 @@ class WordPressHookTests(WebhookTestCase):
|
|||
def test_publish_post_type_not_provided(self) -> None:
|
||||
|
||||
expected_topic = u"WordPress Post"
|
||||
expected_message = u"New post published.\n[New Blog Post](http://example.com\n)"
|
||||
expected_message = u"New post published:\n* [New Blog Post](http://example.com\n)"
|
||||
|
||||
self.send_and_test_stream_message('publish_post_type_not_provided',
|
||||
expected_topic, expected_message,
|
||||
|
@ -27,7 +27,7 @@ class WordPressHookTests(WebhookTestCase):
|
|||
|
||||
# Note: the fixture includes 'hook=publish_post' because it's always added by HookPress
|
||||
expected_topic = u"WordPress Notification"
|
||||
expected_message = u"New post published.\n" + "[New WordPress Post](WordPress Post URL)"
|
||||
expected_message = u"New post published:\n* [New WordPress Post](WordPress Post URL)"
|
||||
|
||||
self.send_and_test_stream_message('publish_post_no_data_provided',
|
||||
expected_topic, expected_message,
|
||||
|
@ -36,7 +36,7 @@ class WordPressHookTests(WebhookTestCase):
|
|||
def test_publish_page(self) -> None:
|
||||
|
||||
expected_topic = u"WordPress Page"
|
||||
expected_message = u"New page published.\n" + "[New Blog Page](http://example.com\n)"
|
||||
expected_message = u"New page published:\n* [New Blog Page](http://example.com\n)"
|
||||
|
||||
self.send_and_test_stream_message('publish_page', expected_topic, expected_message,
|
||||
content_type="application/x-www-form-urlencoded")
|
||||
|
@ -44,7 +44,7 @@ class WordPressHookTests(WebhookTestCase):
|
|||
def test_user_register(self) -> None:
|
||||
|
||||
expected_topic = u"New Blog Users"
|
||||
expected_message = u"New blog user registered.\nName: test_user\nemail: test_user@example.com"
|
||||
expected_message = u"New blog user registered:\n* **Name**: test_user\n* **Email**: test_user@example.com"
|
||||
|
||||
self.send_and_test_stream_message('user_register', expected_topic, expected_message,
|
||||
content_type="application/x-www-form-urlencoded")
|
||||
|
|
|
@ -8,8 +8,15 @@ from zerver.lib.response import json_error, json_success
|
|||
from zerver.lib.webhooks.common import check_send_webhook_message
|
||||
from zerver.models import UserProfile
|
||||
|
||||
PUBLISH_POST_OR_PAGE_TEMPLATE = 'New {type} published.\n[{title}]({url})'
|
||||
USER_REGISTER_TEMPLATE = 'New blog user registered.\nName: {name}\nemail: {email}'
|
||||
PUBLISH_POST_OR_PAGE_TEMPLATE = """
|
||||
New {type} published:
|
||||
* [{title}]({url})
|
||||
""".strip()
|
||||
USER_REGISTER_TEMPLATE = """
|
||||
New blog user registered:
|
||||
* **Name**: {name}
|
||||
* **Email**: {email}
|
||||
""".strip()
|
||||
WP_LOGIN_TEMPLATE = 'User {name} logged in.'
|
||||
|
||||
@api_key_only_webhook_view("Wordpress", notify_bot_owner_on_invalid_json=False)
|
||||
|
|
Loading…
Reference in New Issue