reminder_bot: Add infra for adding reminder bot to every realm.

This commit is contained in:
Aditya Bansal
2018-01-12 13:40:43 +05:30
committed by showell
parent 5a794f9871
commit c770bdaa3a
7 changed files with 73 additions and 3 deletions

View File

@@ -4,11 +4,24 @@ from django.conf import settings
from zerver.lib.actions import set_default_streams, bulk_add_subscriptions, \
internal_prep_stream_message, internal_send_private_message, \
create_stream_if_needed, create_streams_if_needed, do_send_messages, \
do_add_reaction_legacy
do_add_reaction_legacy, create_users
from zerver.models import Realm, UserProfile, Message, Reaction, get_system_bot
from typing import Any, Dict, List, Mapping, Text
def setup_realm_internal_bots(realm: Realm) -> None:
internal_bots = [(bot['name'], bot['email_template'] % (settings.INTERNAL_BOT_DOMAIN,))
for bot in settings.REALM_INTERNAL_BOTS]
create_users(realm, internal_bots, bot_type=UserProfile.DEFAULT_BOT)
bots = UserProfile.objects.filter(
realm=realm,
email__in=[bot_info[1] for bot_info in internal_bots],
bot_owner__isnull=True
)
for bot in bots:
bot.bot_owner = bot
bot.save()
def send_initial_pms(user: UserProfile) -> None:
organization_setup_text = ""
if user.is_realm_admin: