From 8e0b6fa6cf5e1acc6f4ba0715618458602341f5c Mon Sep 17 00:00:00 2001 From: Mateusz Mandera Date: Wed, 24 Jul 2019 08:34:15 +0200 Subject: [PATCH] populate_db: Use separate realm for system bots, like in production. This commit alone breaks things, needs to be merged with the follow-up ones. welcome-bot is removed from the explicit list, because it already is in settings.INTERNAL_BOTS. --- zilencer/management/commands/populate_db.py | 20 +++++++++----------- zproject/settings.py | 2 +- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/zilencer/management/commands/populate_db.py b/zilencer/management/commands/populate_db.py index b6ad5a701b..306af3aaac 100644 --- a/zilencer/management/commands/populate_db.py +++ b/zilencer/management/commands/populate_db.py @@ -177,9 +177,10 @@ class Command(BaseCommand): # Start by clearing all the data in our database clear_database() - # Create our two default realms + # Create our three default realms # Could in theory be done via zerver.lib.actions.do_create_realm, but # welcome-bot (needed for do_create_realm) hasn't been created yet + internal_realm = Realm.objects.create(string_id=settings.SYSTEM_BOT_REALM) zulip_realm = Realm.objects.create( string_id="zulip", name="Zulip Dev", emails_restricted_to_domains=True, description="The Zulip development environment default organization." @@ -223,17 +224,19 @@ class Command(BaseCommand): # These bots are directly referenced from code and thus # are needed for the test suite. - all_realm_bots = [(bot['name'], bot['email_template'] % (settings.INTERNAL_BOT_DOMAIN,)) - for bot in settings.INTERNAL_BOTS] + internal_realm_bots = [(bot['name'], bot['email_template'] % (settings.INTERNAL_BOT_DOMAIN,)) + for bot in settings.INTERNAL_BOTS] + internal_realm_bots += [ + ("Zulip Feedback Bot", "feedback@zulip.com"), + ] zulip_realm_bots = [ ("Zulip Error Bot", "error-bot@zulip.com"), ("Zulip Default Bot", "default-bot@zulip.com"), - ("Welcome Bot", "welcome-bot@zulip.com"), ] - for i in range(options["extra_bots"]): zulip_realm_bots.append(('Extra Bot %d' % (i,), 'extrabot%d@zulip.com' % (i,))) - zulip_realm_bots.extend(all_realm_bots) + + create_users(internal_realm, internal_realm_bots, bot_type=UserProfile.DEFAULT_BOT) create_users(zulip_realm, zulip_realm_bots, bot_type=UserProfile.DEFAULT_BOT) # Initialize the email gateway bot as an API Super User @@ -535,11 +538,6 @@ class Command(BaseCommand): ] create_users(zulip_realm, internal_zulip_users_nosubs, bot_type=UserProfile.DEFAULT_BOT) - zulip_cross_realm_bots = [ - ("Zulip Feedback Bot", "feedback@zulip.com"), - ] - create_users(zulip_realm, zulip_cross_realm_bots, bot_type=UserProfile.DEFAULT_BOT) - # Mark all messages as read UserMessage.objects.all().update(flags=UserMessage.flags.read) diff --git a/zproject/settings.py b/zproject/settings.py index 27307a0756..d4b9b5dd40 100644 --- a/zproject/settings.py +++ b/zproject/settings.py @@ -283,7 +283,7 @@ DEFAULT_SETTINGS.update({ # SYSTEM_BOT_REALM would be a constant always set to 'zulip', # except that it isn't that on zulipchat.com. We will likely do a # migration and eliminate this parameter in the future. - 'SYSTEM_BOT_REALM': 'zulip', + 'SYSTEM_BOT_REALM': 'zulipinternal', # Structurally, we will probably eventually merge # analytics into part of the main server, rather