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.
This commit is contained in:
Tim Abbott
2025-08-13 13:28:30 -07:00
parent 04fe9be715
commit 3e84eaab5d
2 changed files with 10 additions and 5 deletions

View File

@@ -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.markdown.fenced_code import get_unused_fence
from zerver.lib.message import SendMessageRequest, remove_single_newlines from zerver.lib.message import SendMessageRequest, remove_single_newlines
from zerver.models import Message, OnboardingUserMessage, Realm, UserProfile from zerver.models import Message, OnboardingUserMessage, Realm, UserProfile
from zerver.models.groups import SystemGroups
from zerver.models.recipients import Recipient from zerver.models.recipients import Recipient
from zerver.models.users import get_system_bot 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) 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) fence = get_unused_fence(welcome_message_custom_text)
welcome_bot_custom_message_intro_string = _( welcome_bot_custom_message_intro_string = _("A note from {admin_group_syntax}:").format(
"The administrators for this organization would also like to share the following information:" admin_group_syntax=mention_syntax
) )
welcome_bot_custom_message_string = f""" 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. # Add welcome bot custom message.
if welcome_message_custom_text: if welcome_message_custom_text:
welcome_bot_custom_message_string = get_custom_welcome_message_string( welcome_bot_custom_message_string = get_custom_welcome_message_string(
welcome_message_custom_text user.realm, welcome_message_custom_text
) )
content = _(""" content = _("""

View File

@@ -32,7 +32,7 @@ def send_test_welcome_bot_custom_message(
raise JsonableError(_("Message must not be empty")) raise JsonableError(_("Message must not be empty"))
welcome_bot_custom_message_string = get_custom_welcome_message_string( 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( message_id = internal_send_private_message(
get_system_bot(settings.WELCOME_BOT, user_profile.realm_id), get_system_bot(settings.WELCOME_BOT, user_profile.realm_id),