Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
typing: Deduplicate user IDs for self-DM typing notifications.
Tim Abbott8e298bc38418
diff --git a/zerver/tests/test_typing.py b/zerver/tests/test_typing.pyindex d78dd7b7146..214ef4f3222 100644--- a/zerver/tests/test_typing.py+++ b/zerver/tests/test_typing.py@@ -893,3 +893,24 @@ class TestSendTypingNotificationsSettings(ZulipTestCase):self.assert_length(events, 1)event_user_ids = set(events[0]["users"])self.assertEqual(expected_recipient_ids, event_user_ids)++ def test_message_edit_notifications_for_direct_messages_to_self(self) -> None:+ hamlet = self.example_user("hamlet")+ msg_id = self.send_personal_message(hamlet, hamlet)++ params = dict(+ op="start",+ )+ with self.capture_send_event_calls(expected_num_events=1) as events:+ result = self.api_post(hamlet, f"/api/v1/messages/{msg_id}/typing", params)++ self.assert_json_success(result)+ self.assert_length(events, 1)++ # Make sure that hamlet being both the sender and recipient is not included twice.+ self.assert_length(events[0]["users"], 1)+ self.assertEqual([hamlet.id], events[0]["users"])++ event = events[0]["event"]+ self.assert_length(event["recipient"]["user_ids"], 1)+ self.assertEqual([hamlet.id], event["recipient"]["user_ids"])diff --git a/zerver/views/typing.py b/zerver/views/typing.pyindex 5d6a981f8b9..0205349ddf3 100644--- a/zerver/views/typing.py+++ b/zerver/views/typing.py@@ -106,7 +106,8 @@ def send_message_edit_notification_backend(raise JsonableError(_("User has disabled typing notifications for direct messages"))if recipient.type == Recipient.PERSONAL:- recipient_ids = [user_profile.id, recipient.type_id]+ # For self-DMs, both IDs are the same; deduplicate.+ recipient_ids = list({user_profile.id, recipient.type_id})else:recipient_ids = list(get_direct_message_group_user_ids(recipient))