realm creation: Move sending of initial notifications stream message.

Slowly collecting all initial realm messages into
send_initial_realm_messages, so that it is easy to control their order.
This commit is contained in:
Rishi Gupta 2017-07-16 21:29:33 -07:00 committed by Tim Abbott
parent 377e32d77c
commit 70d77c7251
2 changed files with 4 additions and 16 deletions

View File

@ -2292,22 +2292,6 @@ def do_create_realm(string_id, name, restricted_to_domain=None,
realm.notifications_stream = notifications_stream
realm.save(update_fields=['notifications_stream'])
# Include a welcome message in this notifications stream
stream_name = notifications_stream.name
sender = get_system_bot(settings.WELCOME_BOT)
topic = "welcome"
content = """\
This is a message on stream `%s` with the topic `welcome`. We'll use this stream for
system-generated notifications.""" % (stream_name,)
msg = internal_prep_stream_message(
realm=realm,
sender=sender,
stream_name=stream_name,
topic=topic,
content=content)
do_send_messages([msg])
# Log the event
log_event({"type": "realm_created",
"string_id": string_id,

View File

@ -97,6 +97,10 @@ def setup_initial_private_stream(user):
def send_initial_realm_messages(realm):
# type: (Realm) -> None
welcome_messages = [
{'stream': Realm.DEFAULT_NOTIFICATION_STREAM_NAME,
'topic': "welcome",
'content': "This is a message on stream `%s` with the topic `welcome`. We'll use this stream "
"for system-generated notifications." % (Realm.DEFAULT_NOTIFICATION_STREAM_NAME,)},
{'stream': "core team",
'topic': "private streams",
'content': "This is a private stream. Only admins and people you invite "