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.

recipient_info: Include 'sender_id' in 'topic_participant_user_ids'.

Prakhar Pratyush02f3f73b0c86
diff --git a/zerver/actions/message_send.py b/zerver/actions/message_send.py
index d6f56637296..0dcacf122cc 100644
--- a/zerver/actions/message_send.py
+++ b/zerver/actions/message_send.py
@@ -239,6 +239,11 @@ def get_recipient_info(
topic_participant_user_ids = participants_for_topic(
realm_id, recipient.id, stream_topic.topic_name
)
+ # We explicitly include the sender as a topic participant because the message will
+ # be actually sent at a later stage in this codepath, so `participants_for_topic`
+ # misses this sender. This is useful when the sender is sending their first message
+ # in the topic.
+ topic_participant_user_ids.add(sender_id)
subscription_rows = (
get_subscriptions_for_send_message(
realm_id=realm_id,
diff --git a/zerver/tests/test_users.py b/zerver/tests/test_users.py
index 5f79c524170..31adb706442 100644
--- a/zerver/tests/test_users.py
+++ b/zerver/tests/test_users.py
@@ -1967,11 +1967,13 @@ class RecipientInfoTest(ZulipTestCase):
possible_stream_wildcard_mention=False,
)
self.assertEqual(info.stream_wildcard_mention_user_ids, set())
- self.assertEqual(info.topic_wildcard_mention_user_ids, set())
+ self.assertEqual(info.topic_wildcard_mention_user_ids, {hamlet.id})
# User who sent a message to the topic, or reacted to a message on the topic
# is only considered as a possible user to be notified for topic mention.
- self.send_stream_message(hamlet, stream_name, content="test message", topic_name=topic_name)
+ self.send_stream_message(
+ othello, stream_name, content="test message", topic_name=topic_name
+ )
info = get_recipient_info(
realm_id=realm.id,
recipient=recipient,
@@ -1981,7 +1983,7 @@ class RecipientInfoTest(ZulipTestCase):
possible_stream_wildcard_mention=False,
)
self.assertEqual(info.stream_wildcard_mention_user_ids, set())
- self.assertEqual(info.topic_wildcard_mention_user_ids, {hamlet.id})
+ self.assertEqual(info.topic_wildcard_mention_user_ids, {hamlet.id, othello.id})
info = get_recipient_info(
realm_id=realm.id,
@@ -2003,7 +2005,7 @@ class RecipientInfoTest(ZulipTestCase):
possible_stream_wildcard_mention=True,
)
self.assertEqual(info.stream_wildcard_mention_user_ids, {hamlet.id, othello.id})
- self.assertEqual(info.topic_wildcard_mention_user_ids, {hamlet.id})
+ self.assertEqual(info.topic_wildcard_mention_user_ids, {hamlet.id, othello.id})
sub = get_subscription(stream_name, hamlet)
sub.push_notifications = False