mirror of
https://github.com/zulip/zulip.git
synced 2025-11-01 12:33:40 +00:00
notification bot: Modify initial stream creation message.
Discussion at https://chat.zulip.org/#narrow/stream/137-feedback/topic/hello.20topic The "by @**X**" part in the message content is in a later commit.
This commit is contained in:
@@ -121,7 +121,7 @@ IGNORED_PHRASES = [
|
||||
# We should probably just delete this string from translations
|
||||
r'activation key',
|
||||
# this is used as a topic
|
||||
r'^hello$',
|
||||
r'^stream events$',
|
||||
# These are used as example short names (e.g. an uncapitalized context):
|
||||
r"^marketing$",
|
||||
r"^cookie$",
|
||||
|
@@ -1709,20 +1709,11 @@ def check_typing_notification(sender: UserProfile,
|
||||
assert recipient.type != Recipient.STREAM
|
||||
return {'sender': sender, 'recipient': recipient, 'op': operator}
|
||||
|
||||
def stream_welcome_message(stream: Stream) -> str:
|
||||
content = _('Welcome to #**%s**.') % (stream.name,)
|
||||
|
||||
if stream.description:
|
||||
content += '\n\n**' + _('Description') + '**: '
|
||||
content += stream.description
|
||||
|
||||
return content
|
||||
|
||||
def prep_stream_welcome_message(stream: Stream) -> Optional[Dict[str, Any]]:
|
||||
realm = stream.realm
|
||||
sender = get_system_bot(settings.WELCOME_BOT)
|
||||
topic = _('hello')
|
||||
content = stream_welcome_message(stream)
|
||||
sender = get_system_bot(settings.NOTIFICATION_BOT)
|
||||
topic = _('stream events')
|
||||
content = _('Stream created. Welcome!')
|
||||
|
||||
message = internal_prep_stream_message(
|
||||
realm=realm,
|
||||
|
@@ -57,7 +57,6 @@ from zerver.lib.actions import (
|
||||
ensure_stream,
|
||||
do_deactivate_stream,
|
||||
do_deactivate_user,
|
||||
stream_welcome_message,
|
||||
do_create_default_stream_group,
|
||||
do_add_streams_to_default_stream_group, do_remove_streams_from_default_stream_group,
|
||||
do_remove_default_stream_group,
|
||||
@@ -240,32 +239,6 @@ class TestCreateStreams(ZulipTestCase):
|
||||
self.assertFalse(stream.invite_only)
|
||||
self.assertFalse(stream.history_public_to_subscribers)
|
||||
|
||||
def test_welcome_message(self) -> None:
|
||||
realm = get_realm('zulip')
|
||||
name = u'New Stream'
|
||||
|
||||
new_stream = ensure_stream(
|
||||
realm=realm,
|
||||
stream_name=name
|
||||
)
|
||||
welcome_message = stream_welcome_message(new_stream)
|
||||
|
||||
self.assertEqual(
|
||||
welcome_message,
|
||||
u'Welcome to #**New Stream**.'
|
||||
)
|
||||
|
||||
new_stream.description = 'Talk about **stuff**.'
|
||||
|
||||
welcome_message = stream_welcome_message(new_stream)
|
||||
|
||||
self.assertEqual(
|
||||
welcome_message,
|
||||
'Welcome to #**New Stream**.'
|
||||
'\n\n'
|
||||
'**Description**: Talk about **stuff**.'
|
||||
)
|
||||
|
||||
class RecipientTest(ZulipTestCase):
|
||||
def test_recipient(self) -> None:
|
||||
realm = get_realm('zulip')
|
||||
@@ -2334,9 +2307,9 @@ class SubscriptionAPITest(ZulipTestCase):
|
||||
# verify that a welcome message was sent to the stream
|
||||
msg = self.get_last_message()
|
||||
self.assertEqual(msg.recipient.type, msg.recipient.STREAM)
|
||||
self.assertEqual(msg.topic_name(), u'hello')
|
||||
self.assertEqual(msg.sender.email, settings.WELCOME_BOT)
|
||||
self.assertIn('Welcome to #**', msg.content)
|
||||
self.assertEqual(msg.topic_name(), u'stream events')
|
||||
self.assertEqual(msg.sender.email, settings.NOTIFICATION_BOT)
|
||||
self.assertEqual('Stream created. Welcome!', msg.content)
|
||||
|
||||
def test_multi_user_subscription(self) -> None:
|
||||
user1 = self.example_user("cordelia")
|
||||
|
Reference in New Issue
Block a user