zulip_updates: Send an introductory message before the first update.

To help users focus on the onboarding experience, we no longer
send the introductory "Zulip updates" message as a part of
onboarding.

Now, we send the introductory message just before the first
update message.

Fixes #30053.
This commit is contained in:
Prakhar Pratyush
2024-05-14 23:12:42 +05:30
committed by Tim Abbott
parent f73f27b45f
commit e264b12066
4 changed files with 47 additions and 33 deletions

View File

@@ -359,21 +359,6 @@ This **greetings** topic is a great place to say “hi” :wave: to your teammat
:point_right: Click on this message to start a new message in the same conversation.
""")
content_of_zulip_update_announcements_topic_name = (
_("""
Welcome! To help you learn about new features and configuration options,
this topic will receive messages about important changes in Zulip.
You can read these update messages whenever it's convenient, or
[mute]({mute_topic_help_url}) this topic if you are not interested.
If your organization does not want to receive these announcements,
they can be disabled. [Learn more]({zulip_update_announcements_help_url}).
""")
).format(
zulip_update_announcements_help_url="/help/configure-automated-notices#zulip-update-announcements",
mute_topic_help_url="/help/mute-a-topic",
)
welcome_messages: List[Dict[str, str]] = []
# Messages added to the "welcome messages" list last will be most
@@ -383,15 +368,6 @@ they can be disabled. [Learn more]({zulip_update_announcements_help_url}).
#
# Initial messages are configured below.
# Zulip updates system advertisement.
welcome_messages += [
{
"channel_name": str(Realm.DEFAULT_NOTIFICATION_STREAM_NAME),
"topic_name": str(Realm.ZULIP_UPDATE_ANNOUNCEMENTS_TOPIC_NAME),
"content": content_of_zulip_update_announcements_topic_name,
},
]
# Advertising moving messages.
welcome_messages += [
{

View File

@@ -14,6 +14,7 @@ from zerver.actions.message_send import (
internal_prep_stream_message,
)
from zerver.lib.message import SendMessageRequest, remove_single_newlines
from zerver.lib.topic import messages_for_topic
from zerver.models.realm_audit_logs import RealmAuditLog
from zerver.models.realms import Realm
from zerver.models.users import UserProfile, get_system_bot
@@ -264,11 +265,47 @@ def send_zulip_update_announcements(
):
continue
messages = internal_prep_zulip_update_announcements_stream_messages(
current_level=realm_zulip_update_announcements_level,
latest_level=latest_zulip_update_announcements_level,
sender=sender,
realm=realm,
# Send an introductory message just before the first update message.
with override_language(realm.default_language):
topic_name = str(realm.ZULIP_UPDATE_ANNOUNCEMENTS_TOPIC_NAME)
stream = realm.zulip_update_announcements_stream
assert stream.recipient_id is not None
topic_has_messages = messages_for_topic(
realm.id, stream.recipient_id, topic_name
).exists()
if not topic_has_messages:
content_of_introductory_message = (
"""
To help you learn about new features and configuration options,
this topic will receive messages about important changes in Zulip.
You can read these update messages whenever it's convenient, or
[mute]({mute_topic_help_url}) this topic if you are not interested.
If your organization does not want to receive these announcements,
they can be disabled. [Learn more]({zulip_update_announcements_help_url}).
"""
).format(
zulip_update_announcements_help_url="/help/configure-automated-notices#zulip-update-announcements",
mute_topic_help_url="/help/mute-a-topic",
)
messages = [
internal_prep_stream_message(
sender,
stream,
topic_name,
remove_single_newlines(content_of_introductory_message),
)
]
messages.extend(
internal_prep_zulip_update_announcements_stream_messages(
current_level=realm_zulip_update_announcements_level,
latest_level=latest_zulip_update_announcements_level,
sender=sender,
realm=realm,
)
)
new_zulip_update_announcements_level = latest_zulip_update_announcements_level

View File

@@ -1305,7 +1305,7 @@ class RealmCreationTest(ZulipTestCase):
# Check welcome messages
for stream_name, text, message_count in [
(str(Realm.DEFAULT_NOTIFICATION_STREAM_NAME), "learn about new features", 3),
(str(Realm.DEFAULT_NOTIFICATION_STREAM_NAME), "a great place to say “hi”", 2),
(str(Realm.ZULIP_SANDBOX_CHANNEL_NAME), "Use this topic to try out", 5),
]:
stream = get_stream(stream_name, realm)

View File

@@ -122,9 +122,10 @@ class ZulipUpdateAnnouncementsTest(ZulipTestCase):
recipient__type_id=verona.id,
date_sent__gte=now + timedelta(days=10),
).order_by("id")
self.assert_length(stream_messages, 2)
self.assertEqual(stream_messages[0].content, "Announcement message 3.")
self.assertEqual(stream_messages[1].content, "Announcement message 4.")
self.assert_length(stream_messages, 3)
self.assertIn("To help you learn about new features", stream_messages[0].content)
self.assertEqual(stream_messages[1].content, "Announcement message 3.")
self.assertEqual(stream_messages[2].content, "Announcement message 4.")
self.assertEqual(realm.zulip_update_announcements_level, 4)
def test_send_zulip_update_announcements_with_stream_configured(self) -> None: