Skip to content

Commit

Permalink
Make initial messages in initial streams on realm creation customizable.
Browse files Browse the repository at this point in the history
actions.py: modify logic to create streams with welcome messages
settings.py: add custom_welcome_message setting to default streams
models.py: make default notification stream welcome message customizable
  • Loading branch information
jrowan committed Jun 19, 2017
1 parent 7e99262 commit fd7eeb7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
13 changes: 5 additions & 8 deletions zerver/lib/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2236,18 +2236,13 @@ def do_create_realm(string_id, name, restricted_to_domain=None,
# Include a welcome message in this notifications stream
stream_name = notifications_stream.name
sender = get_system_bot(settings.WELCOME_BOT)
topic = "welcome"
content = """Hello, and welcome to Zulip!
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)
topic=Realm.DEFAULT_NOTIFICATION_STREAM_WELCOME_MESSAGE_TOPIC,
content=Realm.DEFAULT_NOTIFICATION_STREAM_WELCOME_MESSAGE)
do_send_messages([msg])

# Log the event
Expand Down Expand Up @@ -2348,7 +2343,9 @@ def create_streams_with_welcome_messages(realm, stream_dict):
)

if created:
message = prep_stream_welcome_message(stream)
message = options.get("custom_welcome_message")
if message is None:
message = prep_stream_welcome_message(stream)
messages.append(message)

if messages:
Expand Down
5 changes: 5 additions & 0 deletions zerver/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ class Realm(ModelReprMixin, models.Model):
icon_version = models.PositiveSmallIntegerField(default=1) # type: int

DEFAULT_NOTIFICATION_STREAM_NAME = u'announce'
DEFAULT_NOTIFICATION_STREAM_WELCOME_MESSAGE_TOPIC = "welcome"
DEFAULT_NOTIFICATION_STREAM_WELCOME_MESSAGE = """Hello, and welcome to Zulip!
This is a message on stream `%s` with the topic `welcome`. We'll use this stream for
system-generated notifications.""" % (DEFAULT_NOTIFICATION_STREAM_NAME,)

def authentication_methods_dict(self):
# type: () -> Dict[Text, bool]
Expand Down
9 changes: 6 additions & 3 deletions zproject/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,12 @@ def get_secret(key):
# than a separate app.
'EXTRA_INSTALLED_APPS': ['analytics'],
'DEFAULT_NEW_REALM_STREAMS': {
"social": {"description": "For socializing", "invite_only": False},
"general": {"description": "For general stuff", "invite_only": False},
"zulip": {"description": "For zulip stuff", "invite_only": False}
"social": {"description": "For socializing", "invite_only": False,
"custom_welcome_message": None},
"general": {"description": "For general stuff", "invite_only": False,
"custom_welcome_message": None},
"zulip": {"description": "For zulip stuff", "invite_only": False,
"custom_welcome_message": None}
},
'REALM_CREATION_LINK_VALIDITY_DAYS': 7,
'TERMS_OF_SERVICE': None,
Expand Down

0 comments on commit fd7eeb7

Please sign in to comment.