Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
missedmessage_hook: Don't enqueue notificationss if sender is muted.
Abhijeet Prasad Bodas5a642cea115b
diff --git a/zerver/tests/test_event_queue.py b/zerver/tests/test_event_queue.pyindex e3333d8ca08..469dbaab697 100644--- a/zerver/tests/test_event_queue.py+++ b/zerver/tests/test_event_queue.py@@ -523,6 +523,20 @@ class MissedMessageNotificationsTest(ZulipTestCase):user_profile, stream, sub, {"push_notifications": True, "is_muted": False})+ # Test the hook when the sender has been muted+ result = self.api_post(user_profile, f"/api/v1/users/me/muted_users/{iago.id}")+ self.assert_json_success(result)+ client_descriptor = allocate_event_queue()+ self.assertTrue(client_descriptor.event_queue.empty())+ msg_id = self.send_personal_message(iago, user_profile)+ with mock.patch("zerver.tornado.event_queue.maybe_enqueue_notifications") as mock_enqueue:+ missedmessage_hook(user_profile.id, client_descriptor, True)+ # If the sender is muted, we don't call `maybe_enqueue_notifications` at all.+ mock_enqueue.assert_not_called()+ destroy_event_queue(client_descriptor.event_queue.id)+ result = self.api_delete(user_profile, f"/api/v1/users/me/muted_users/{iago.id}")+ self.assert_json_success(result)+class FileReloadLogicTest(ZulipTestCase):def test_persistent_queue_filename(self) -> None:diff --git a/zerver/tornado/event_queue.py b/zerver/tornado/event_queue.pyindex 1f397676a78..521c38b86a1 100644--- a/zerver/tornado/event_queue.py+++ b/zerver/tornado/event_queue.py@@ -736,6 +736,10 @@ def missedmessage_hook(internal_data = event.get("internal_data", {})+ sender_is_muted = internal_data.get("sender_is_muted", False)+ if sender_is_muted:+ continue+assert "flags" in eventflags = event["flags"]@@ -960,6 +964,7 @@ def process_message_event(stream_push_notify=stream_push_notify,stream_email_notify=stream_email_notify,wildcard_mention_notify=wildcard_mention_notify,+ sender_is_muted=sender_is_muted,),)