Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
maybe_enqueue_notifications: Require all keyword arguments.
Abhijeet Prasad Bodasf6e705d477da
diff --git a/zerver/tests/test_event_queue.py b/zerver/tests/test_event_queue.pyindex 30be7fdcdc6..102fd6f40bf 100644--- a/zerver/tests/test_event_queue.py+++ b/zerver/tests/test_event_queue.py@@ -245,28 +245,26 @@ class MissedMessageNotificationsTest(ZulipTestCase):self.assert_json_success(result)def assert_maybe_enqueue_notifications_call_args(- args_list: Collection[Any],+ args_dict: Collection[Any],user_profile_id: int,message_id: int,**kwargs: Union[bool, Dict[str, bool], Optional[str]],) -> None:kwargs = self.get_maybe_enqueue_notifications_parameters(**kwargs)- self.assertEqual(- args_list,- (- user_profile_id,- message_id,- kwargs["private_message"],- kwargs["mentioned"],- kwargs["wildcard_mention_notify"],- kwargs["stream_push_notify"],- kwargs["stream_email_notify"],- kwargs["stream_name"],- kwargs["online_push_enabled"],- kwargs["idle"],- kwargs["already_notified"],- ),+ expected_args_dict = dict(+ user_profile_id=user_profile_id,+ message_id=message_id,+ private_message=kwargs["private_message"],+ mentioned=kwargs["mentioned"],+ wildcard_mention_notify=kwargs["wildcard_mention_notify"],+ stream_push_notify=kwargs["stream_push_notify"],+ stream_email_notify=kwargs["stream_email_notify"],+ stream_name=kwargs["stream_name"],+ online_push_enabled=kwargs["online_push_enabled"],+ idle=kwargs["idle"],+ already_notified=kwargs["already_notified"],)+ self.assertEqual(args_dict, expected_args_dict)client_descriptor = allocate_event_queue()with mock.patch("zerver.tornado.event_queue.maybe_enqueue_notifications") as mock_enqueue:@@ -283,10 +281,10 @@ class MissedMessageNotificationsTest(ZulipTestCase):# Now verify that we called the appropriate enqueue functionmissedmessage_hook(user_profile.id, client_descriptor, True)mock_enqueue.assert_called_once()- args_list = mock_enqueue.call_args_list[0][0]+ args_dict = mock_enqueue.call_args_list[0][1]assert_maybe_enqueue_notifications_call_args(- args_list=args_list,+ args_dict=args_dict,user_profile_id=user_profile.id,message_id=msg_id,stream_name="Denmark",@@ -301,10 +299,10 @@ class MissedMessageNotificationsTest(ZulipTestCase):with mock.patch("zerver.tornado.event_queue.maybe_enqueue_notifications") as mock_enqueue:missedmessage_hook(user_profile.id, client_descriptor, True)mock_enqueue.assert_called_once()- args_list = mock_enqueue.call_args_list[0][0]+ args_dict = mock_enqueue.call_args_list[0][1]assert_maybe_enqueue_notifications_call_args(- args_list=args_list,+ args_dict=args_dict,user_profile_id=user_profile.id,message_id=msg_id,private_message=True,@@ -321,10 +319,10 @@ class MissedMessageNotificationsTest(ZulipTestCase):with mock.patch("zerver.tornado.event_queue.maybe_enqueue_notifications") as mock_enqueue:missedmessage_hook(user_profile.id, client_descriptor, True)mock_enqueue.assert_called_once()- args_list = mock_enqueue.call_args_list[0][0]+ args_dict = mock_enqueue.call_args_list[0][1]assert_maybe_enqueue_notifications_call_args(- args_list=args_list,+ args_dict=args_dict,user_profile_id=user_profile.id,message_id=msg_id,mentioned=True,@@ -340,10 +338,10 @@ class MissedMessageNotificationsTest(ZulipTestCase):with mock.patch("zerver.tornado.event_queue.maybe_enqueue_notifications") as mock_enqueue:missedmessage_hook(user_profile.id, client_descriptor, True)mock_enqueue.assert_called_once()- args_list = mock_enqueue.call_args_list[0][0]+ args_dict = mock_enqueue.call_args_list[0][1]assert_maybe_enqueue_notifications_call_args(- args_list=args_list,+ args_dict=args_dict,user_profile_id=user_profile.id,message_id=msg_id,wildcard_mention_notify=True,@@ -360,10 +358,10 @@ class MissedMessageNotificationsTest(ZulipTestCase):with mock.patch("zerver.tornado.event_queue.maybe_enqueue_notifications") as mock_enqueue:missedmessage_hook(user_profile.id, client_descriptor, True)mock_enqueue.assert_called_once()- args_list = mock_enqueue.call_args_list[0][0]+ args_dict = mock_enqueue.call_args_list[0][1]assert_maybe_enqueue_notifications_call_args(- args_list=args_list,+ args_dict=args_dict,user_profile_id=user_profile.id,message_id=msg_id,stream_name="Denmark",@@ -381,10 +379,10 @@ class MissedMessageNotificationsTest(ZulipTestCase):with mock.patch("zerver.tornado.event_queue.maybe_enqueue_notifications") as mock_enqueue:missedmessage_hook(user_profile.id, client_descriptor, True)mock_enqueue.assert_called_once()- args_list = mock_enqueue.call_args_list[0][0]+ args_dict = mock_enqueue.call_args_list[0][1]assert_maybe_enqueue_notifications_call_args(- args_list=args_list,+ args_dict=args_dict,user_profile_id=user_profile.id,message_id=msg_id,stream_name="Denmark",@@ -406,10 +404,10 @@ class MissedMessageNotificationsTest(ZulipTestCase):with mock.patch("zerver.tornado.event_queue.maybe_enqueue_notifications") as mock_enqueue:missedmessage_hook(user_profile.id, client_descriptor, True)mock_enqueue.assert_called_once()- args_list = mock_enqueue.call_args_list[0][0]+ args_dict = mock_enqueue.call_args_list[0][1]assert_maybe_enqueue_notifications_call_args(- args_list=args_list,+ args_dict=args_dict,user_profile_id=user_profile.id,message_id=msg_id,wildcard_mention_notify=True,@@ -430,10 +428,10 @@ class MissedMessageNotificationsTest(ZulipTestCase):with mock.patch("zerver.tornado.event_queue.maybe_enqueue_notifications") as mock_enqueue:missedmessage_hook(user_profile.id, client_descriptor, True)mock_enqueue.assert_called_once()- args_list = mock_enqueue.call_args_list[0][0]+ args_dict = mock_enqueue.call_args_list[0][1]assert_maybe_enqueue_notifications_call_args(- args_list=args_list,+ args_dict=args_dict,user_profile_id=user_profile.id,message_id=msg_id,stream_push_notify=True,@@ -453,10 +451,10 @@ class MissedMessageNotificationsTest(ZulipTestCase):with mock.patch("zerver.tornado.event_queue.maybe_enqueue_notifications") as mock_enqueue:missedmessage_hook(user_profile.id, client_descriptor, True)mock_enqueue.assert_called_once()- args_list = mock_enqueue.call_args_list[0][0]+ args_dict = mock_enqueue.call_args_list[0][1]assert_maybe_enqueue_notifications_call_args(- args_list=args_list,+ args_dict=args_dict,user_profile_id=user_profile.id,message_id=msg_id,stream_push_notify=False,@@ -484,10 +482,10 @@ class MissedMessageNotificationsTest(ZulipTestCase):with mock.patch("zerver.tornado.event_queue.maybe_enqueue_notifications") as mock_enqueue:missedmessage_hook(user_profile.id, client_descriptor, True)mock_enqueue.assert_called_once()- args_list = mock_enqueue.call_args_list[0][0]+ args_dict = mock_enqueue.call_args_list[0][1]assert_maybe_enqueue_notifications_call_args(- args_list=args_list,+ args_dict=args_dict,user_profile_id=user_profile.id,message_id=msg_id,stream_name="Denmark",@@ -508,10 +506,10 @@ class MissedMessageNotificationsTest(ZulipTestCase):with mock.patch("zerver.tornado.event_queue.maybe_enqueue_notifications") as mock_enqueue:missedmessage_hook(user_profile.id, client_descriptor, True)mock_enqueue.assert_called_once()- args_list = mock_enqueue.call_args_list[0][0]+ args_dict = mock_enqueue.call_args_list[0][1]assert_maybe_enqueue_notifications_call_args(- args_list=args_list,+ args_dict=args_dict,user_profile_id=user_profile.id,message_id=msg_id,stream_name="Denmark",diff --git a/zerver/tornado/event_queue.py b/zerver/tornado/event_queue.pyindex 91369597b81..4de7682ab8c 100644--- a/zerver/tornado/event_queue.py+++ b/zerver/tornado/event_queue.py@@ -767,17 +767,17 @@ def missedmessage_hook(email_notified=internal_data.get("email_notified", False),)maybe_enqueue_notifications(- user_profile_id,- message_id,- private_message,- mentioned,- wildcard_mention_notify,- stream_push_notify,- stream_email_notify,- stream_name,- online_push_enabled,- idle,- already_notified,+ user_profile_id=user_profile_id,+ message_id=message_id,+ private_message=private_message,+ mentioned=mentioned,+ wildcard_mention_notify=wildcard_mention_notify,+ stream_push_notify=stream_push_notify,+ stream_email_notify=stream_email_notify,+ stream_name=stream_name,+ online_push_enabled=online_push_enabled,+ idle=idle,+ already_notified=already_notified,)@@ -793,6 +793,7 @@ def receiver_is_off_zulip(user_profile_id: int) -> bool:def maybe_enqueue_notifications(+ *,user_profile_id: int,message_id: int,private_message: bool,@@ -984,17 +985,17 @@ def process_message_event(extra_user_data[user_profile_id]["internal_data"].update(maybe_enqueue_notifications(- user_profile_id,- message_id,- private_message,- user_notifications_data.mentioned,- user_notifications_data.wildcard_mention_notify,- user_notifications_data.stream_push_notify,- user_notifications_data.stream_email_notify,- stream_name,- user_notifications_data.online_push_enabled,- idle,- {},+ user_profile_id=user_profile_id,+ message_id=message_id,+ private_message=private_message,+ mentioned=user_notifications_data.mentioned,+ wildcard_mention_notify=user_notifications_data.wildcard_mention_notify,+ stream_push_notify=user_notifications_data.stream_push_notify,+ stream_email_notify=user_notifications_data.stream_email_notify,+ stream_name=stream_name,+ online_push_enabled=user_notifications_data.online_push_enabled,+ idle=idle,+ already_notified={},))