Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
onboarding: Improve welcome bot custom message wrapper.
Tim Abbott3e84eaab5dc5
diff --git a/zerver/lib/onboarding.py b/zerver/lib/onboarding.pyindex 1c15ed01ea5..62c31f03718 100644--- a/zerver/lib/onboarding.py+++ b/zerver/lib/onboarding.py@@ -19,6 +19,7 @@ from zerver.lib.emoji import get_emoji_datafrom zerver.lib.markdown.fenced_code import get_unused_fencefrom zerver.lib.message import SendMessageRequest, remove_single_newlinesfrom zerver.models import Message, OnboardingUserMessage, Realm, UserProfile+from zerver.models.groups import SystemGroupsfrom zerver.models.recipients import Recipientfrom zerver.models.users import get_system_bot@@ -50,10 +51,14 @@ def create_if_missing_realm_internal_bots() -> None:setup_realm_internal_bots(realm)-def get_custom_welcome_message_string(welcome_message_custom_text: str) -> str:+def get_custom_welcome_message_string(realm: Realm, welcome_message_custom_text: str) -> str:+ # TODO: This could use silent_mention_syntax_for_user_group, but+ # it's not worth doing a database query to get the NamedUserGroup,+ # so some refactoring is required to do that.+ mention_syntax = f"@_*{SystemGroups.ADMINISTRATORS}*"fence = get_unused_fence(welcome_message_custom_text)- welcome_bot_custom_message_intro_string = _(- "The administrators for this organization would also like to share the following information:"+ welcome_bot_custom_message_intro_string = _("A note from {admin_group_syntax}:").format(+ admin_group_syntax=mention_syntax)welcome_bot_custom_message_string = f"""@@ -130,7 +135,7 @@ You can always come back to the [Welcome to Zulip video]({navigation_tour_video_# Add welcome bot custom message.if welcome_message_custom_text:welcome_bot_custom_message_string = get_custom_welcome_message_string(- welcome_message_custom_text+ user.realm, welcome_message_custom_text)content = _("""diff --git a/zerver/views/welcome_bot_custom_message.py b/zerver/views/welcome_bot_custom_message.pyindex 9c9541980cd..106b5827b33 100644--- a/zerver/views/welcome_bot_custom_message.py+++ b/zerver/views/welcome_bot_custom_message.py@@ -32,7 +32,7 @@ def send_test_welcome_bot_custom_message(raise JsonableError(_("Message must not be empty"))welcome_bot_custom_message_string = get_custom_welcome_message_string(- welcome_message_custom_text+ user_profile.realm, welcome_message_custom_text)message_id = internal_send_private_message(get_system_bot(settings.WELCOME_BOT, user_profile.realm_id),