From 3e84eaab5dc5979f0f535aa914dcd5ece48a2943 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Wed, 13 Aug 2025 13:28:30 -0700 Subject: [PATCH] onboarding: Improve welcome bot custom message wrapper. The previous text was rather wordy, and using a silent mention makes it clear who has the ability to control this group, and who one can potentially contact with questions. --- zerver/lib/onboarding.py | 13 +++++++++---- zerver/views/welcome_bot_custom_message.py | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/zerver/lib/onboarding.py b/zerver/lib/onboarding.py index 1c15ed01ea..62c31f0371 100644 --- a/zerver/lib/onboarding.py +++ b/zerver/lib/onboarding.py @@ -19,6 +19,7 @@ from zerver.lib.emoji import get_emoji_data from zerver.lib.markdown.fenced_code import get_unused_fence from zerver.lib.message import SendMessageRequest, remove_single_newlines from zerver.models import Message, OnboardingUserMessage, Realm, UserProfile +from zerver.models.groups import SystemGroups from zerver.models.recipients import Recipient from 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.py index 9c9541980c..106b5827b3 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),