diff --git a/zerver/lib/onboarding.py b/zerver/lib/onboarding.py index 9055d7d057..2a5688f858 100644 --- a/zerver/lib/onboarding.py +++ b/zerver/lib/onboarding.py @@ -1,14 +1,14 @@ from django.conf import settings -from zerver.lib.actions import set_default_streams, \ +from zerver.lib.actions import \ internal_prep_stream_message_by_name, internal_send_private_message, \ - create_streams_if_needed, do_send_messages, \ + do_send_messages, \ do_add_reaction_legacy, create_users, missing_any_realm_internal_bots from zerver.lib.topic import get_turtle_message from zerver.models import Realm, UserProfile, get_system_bot -from typing import Any, Dict, List, Mapping +from typing import Dict, List def setup_realm_internal_bots(realm: Realm) -> None: """Create this realm's internal bots. @@ -60,25 +60,13 @@ def send_initial_pms(user: UserProfile) -> None: internal_send_private_message(user.realm, get_system_bot(settings.WELCOME_BOT), user, content) -def setup_initial_streams(realm: Realm) -> None: - stream_dicts = [ - {'name': "announce"}, - {'name': "new members", - 'description': "For welcoming and onboarding new members. If you haven't yet, " - "introduce yourself in a new thread using your name as the topic!"}, - {'name': "zulip", - 'description': "For discussing Zulip, Zulip tips and tricks, and asking " - "questions about how Zulip works"}] # type: List[Mapping[str, Any]] - create_streams_if_needed(realm, stream_dicts) - set_default_streams(realm, {stream['name']: {} for stream in stream_dicts}) - def send_initial_realm_messages(realm: Realm) -> None: welcome_bot = get_system_bot(settings.WELCOME_BOT) # Make sure each stream created in the realm creation process has at least one message below # Order corresponds to the ordering of the streams on the left sidebar, to make the initial Home # view slightly less overwhelming welcome_messages = [ - {'stream': "announce", + {'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,)}, @@ -86,26 +74,19 @@ def send_initial_realm_messages(realm: Realm) -> None: 'topic': "private streams", 'content': "This is a private stream. Only admins and people you invite " "to the stream will be able to see that this stream exists."}, - {'stream': "general", - 'topic': "welcome", - 'content': "Welcome to #**general**."}, - {'stream': "new members", - 'topic': "onboarding", - 'content': "A #**new members** stream is great for onboarding new members.\n\nIf you're " - "reading this and aren't the first person here, introduce yourself in a new thread " - "using your name as the topic! Type `c` or click on `New Topic` at the bottom of the " - "screen to start a new topic."}, - {'stream': "zulip", + {'stream': Realm.DEFAULT_NOTIFICATION_STREAM_NAME, 'topic': "topic demonstration", 'content': "Here is a message in one topic. Replies to this message will go to this topic."}, - {'stream': "zulip", + {'stream': Realm.DEFAULT_NOTIFICATION_STREAM_NAME, 'topic': "topic demonstration", 'content': "A second message in this topic. With [turtles](/static/images/cute/turtle.png)!"}, - {'stream': "zulip", + {'stream': Realm.DEFAULT_NOTIFICATION_STREAM_NAME, 'topic': "second topic", 'content': "This is a message in a second topic.\n\nTopics are similar to email subjects, " "in that each conversation should get its own topic. Keep them short, though; one " - "or two words will do it!"}, + "or two words will do it! " + "Type `c` or click on `New Topic` at the bottom of the " + "screen to start a new topic."}, ] # type: List[Dict[str, str]] messages = [internal_prep_stream_message_by_name( realm, welcome_bot, message['stream'], diff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.py index 89ee69d6a6..ed9c8c284d 100644 --- a/zerver/tests/test_signup.py +++ b/zerver/tests/test_signup.py @@ -1713,11 +1713,8 @@ class RealmCreationTest(ZulipTestCase): # Check welcome messages for stream_name, text, message_count in [ - ('announce', 'This is', 1), - (Realm.INITIAL_PRIVATE_STREAM_NAME, 'This is', 1), - ('general', 'Welcome to', 1), - ('new members', 'stream is', 1), - ('zulip', 'Here is', 3)]: + (Realm.DEFAULT_NOTIFICATION_STREAM_NAME, 'with the topic', 4), + (Realm.INITIAL_PRIVATE_STREAM_NAME, 'private stream', 1)]: stream = get_stream(stream_name, realm) recipient = get_stream_recipient(stream.id) messages = Message.objects.filter(recipient=recipient).order_by('pub_date') diff --git a/zerver/views/registration.py b/zerver/views/registration.py index 40fb3b64e2..2fb723e739 100644 --- a/zerver/views/registration.py +++ b/zerver/views/registration.py @@ -18,15 +18,14 @@ from zerver.models import UserProfile, Realm, Stream, MultiuseInvite, \ from zerver.lib.send_email import send_email, FromAddress from zerver.lib.actions import do_change_password, do_change_full_name, \ do_activate_user, do_create_user, do_create_realm, \ - validate_email_for_realm, \ + validate_email_for_realm, set_default_streams, \ do_set_user_display_setting, lookup_default_stream_groups, bulk_add_subscriptions from zerver.forms import RegistrationForm, HomepageForm, RealmCreationForm, \ FindMyTeamForm, RealmRedirectForm from django_auth_ldap.backend import LDAPBackend, _LDAPUser from zerver.decorator import require_post, \ do_login -from zerver.lib.onboarding import setup_initial_streams, \ - send_initial_realm_messages, setup_realm_internal_bots +from zerver.lib.onboarding import send_initial_realm_messages, setup_realm_internal_bots from zerver.lib.subdomains import get_subdomain, is_root_domain_available from zerver.lib.timezone import get_all_timezones from zerver.lib.users import get_accounts_for_email @@ -194,7 +193,7 @@ def accounts_register(request: HttpRequest) -> HttpResponse: string_id = form.cleaned_data['realm_subdomain'] realm_name = form.cleaned_data['realm_name'] realm = do_create_realm(string_id, realm_name) - setup_initial_streams(realm) + set_default_streams(realm, {}) setup_realm_internal_bots(realm) assert(realm is not None) diff --git a/zilencer/management/commands/add_new_realm.py b/zilencer/management/commands/add_new_realm.py index 7391d5a64f..de9e8172f0 100644 --- a/zilencer/management/commands/add_new_realm.py +++ b/zilencer/management/commands/add_new_realm.py @@ -1,9 +1,9 @@ from typing import Any -from zerver.lib.actions import do_create_realm, do_create_user, bulk_add_subscriptions +from zerver.lib.actions import do_create_realm, do_create_user, \ + bulk_add_subscriptions, set_default_streams from zerver.lib.management import ZulipBaseCommand -from zerver.lib.onboarding import send_initial_realm_messages, \ - setup_initial_streams +from zerver.lib.onboarding import send_initial_realm_messages from zerver.models import Realm, UserProfile class Command(ZulipBaseCommand): @@ -13,7 +13,7 @@ class Command(ZulipBaseCommand): string_id = 'realm%02d' % ( Realm.objects.filter(string_id__startswith='realm').count(),) realm = do_create_realm(string_id, string_id) - setup_initial_streams(realm) + set_default_streams(realm, {}) name = '%02d-user' % ( UserProfile.objects.filter(email__contains='user@').count(),)