Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

onboarding: Move send_welcome_bot_response to onboarding.

Vishnu KS6bbcb622e10f
diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py
index 24e99e8292c..71ee8925c2d 100644
--- a/zerver/lib/actions.py
+++ b/zerver/lib/actions.py
@@ -1065,22 +1065,6 @@ def create_mirror_user_if_needed(realm: Realm, email: str,
except IntegrityError:
return get_user_by_delivery_email(email, realm)
-def send_welcome_bot_response(message: MutableMapping[str, Any]) -> None:
- welcome_bot = get_system_bot(settings.WELCOME_BOT)
- human_recipient_id = message['message'].sender.recipient_id
- if Message.objects.filter(sender=welcome_bot, recipient_id=human_recipient_id).count() < 2:
- content = (
- _("Congratulations on your first reply!") +
- " "
- ":tada:"
- "\n"
- "\n" +
- _("Feel free to continue using this space to practice your new messaging "
- "skills. Or, try clicking on some of the stream names to your left!")
- )
- internal_send_private_message(
- message['realm'], welcome_bot, message['message'].sender, content)
-
def render_incoming_message(message: Message,
content: str,
user_ids: Set[int],
@@ -1635,6 +1619,7 @@ def do_send_messages(messages_maybe_none: Sequence[Optional[MutableMapping[str,
welcome_bot_id = get_system_bot(settings.WELCOME_BOT).id
if (welcome_bot_id in message['active_user_ids'] and
welcome_bot_id != message['message'].sender_id):
+ from zerver.lib.onboarding import send_welcome_bot_response
send_welcome_bot_response(message)
for queue_name, events in message['message'].service_queue_events.items():
diff --git a/zerver/lib/onboarding.py b/zerver/lib/onboarding.py
index 9b8b593a2d5..2a04e31614c 100644
--- a/zerver/lib/onboarding.py
+++ b/zerver/lib/onboarding.py
@@ -1,4 +1,4 @@
-from typing import Dict, List
+from typing import Any, Dict, List, MutableMapping
from django.conf import settings
from django.db.models import Count
@@ -95,6 +95,22 @@ def send_initial_pms(user: UserProfile) -> None:
internal_send_private_message(user.realm, get_system_bot(settings.WELCOME_BOT),
user, content)
+def send_welcome_bot_response(message: MutableMapping[str, Any]) -> None:
+ welcome_bot = get_system_bot(settings.WELCOME_BOT)
+ human_recipient_id = message['message'].sender.recipient_id
+ if Message.objects.filter(sender=welcome_bot, recipient_id=human_recipient_id).count() < 2:
+ content = (
+ _("Congratulations on your first reply!") +
+ " "
+ ":tada:"
+ "\n"
+ "\n" +
+ _("Feel free to continue using this space to practice your new messaging "
+ "skills. Or, try clicking on some of the stream names to your left!")
+ )
+ internal_send_private_message(
+ message['realm'], welcome_bot, message['message'].sender, content)
+
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