mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 06:53:25 +00:00
event_queue: Consistently user user_notifications_data as variable name.
This disambiguates this object from the those sent via the `send_event` calls, which are also called "user_data".
This commit is contained in:
committed by
Tim Abbott
parent
733e0ae75e
commit
e196ea7e64
@@ -1350,7 +1350,7 @@ Output:
|
|||||||
user_id=user_id, **kwargs
|
user_id=user_id, **kwargs
|
||||||
)
|
)
|
||||||
return dict(
|
return dict(
|
||||||
user_data=user_notifications_data,
|
user_notifications_data=user_notifications_data,
|
||||||
message_id=message_id,
|
message_id=message_id,
|
||||||
acting_user_id=acting_user_id,
|
acting_user_id=acting_user_id,
|
||||||
private_message=kwargs.get("private_message", False),
|
private_message=kwargs.get("private_message", False),
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ class EditMessageSideEffectsTest(ZulipTestCase):
|
|||||||
cordelia_calls = [
|
cordelia_calls = [
|
||||||
call_args
|
call_args
|
||||||
for call_args in m.call_args_list
|
for call_args in m.call_args_list
|
||||||
if call_args[1]["user_data"].user_id == cordelia.id
|
if call_args[1]["user_notifications_data"].user_id == cordelia.id
|
||||||
]
|
]
|
||||||
|
|
||||||
if expect_short_circuit:
|
if expect_short_circuit:
|
||||||
|
|||||||
@@ -312,7 +312,7 @@ class MutedUsersTests(ZulipTestCase):
|
|||||||
self.assert_json_success(result)
|
self.assert_json_success(result)
|
||||||
m.assert_called_once()
|
m.assert_called_once()
|
||||||
# `maybe_enqueue_notificaions` was called for Hamlet after message edit mentioned him.
|
# `maybe_enqueue_notificaions` was called for Hamlet after message edit mentioned him.
|
||||||
self.assertEqual(m.call_args_list[0][1]["user_data"].user_id, hamlet.id)
|
self.assertEqual(m.call_args_list[0][1]["user_notifications_data"].user_id, hamlet.id)
|
||||||
|
|
||||||
# Hamlet mutes Cordelia.
|
# Hamlet mutes Cordelia.
|
||||||
self.login("hamlet")
|
self.login("hamlet")
|
||||||
|
|||||||
@@ -767,7 +767,7 @@ def missedmessage_hook(
|
|||||||
email_notified=internal_data.get("email_notified", False),
|
email_notified=internal_data.get("email_notified", False),
|
||||||
)
|
)
|
||||||
maybe_enqueue_notifications(
|
maybe_enqueue_notifications(
|
||||||
user_data=user_notifications_data,
|
user_notifications_data=user_notifications_data,
|
||||||
acting_user_id=sender_id,
|
acting_user_id=sender_id,
|
||||||
message_id=message_id,
|
message_id=message_id,
|
||||||
private_message=private_message,
|
private_message=private_message,
|
||||||
@@ -790,7 +790,7 @@ def receiver_is_off_zulip(user_profile_id: int) -> bool:
|
|||||||
|
|
||||||
def maybe_enqueue_notifications(
|
def maybe_enqueue_notifications(
|
||||||
*,
|
*,
|
||||||
user_data: UserMessageNotificationsData,
|
user_notifications_data: UserMessageNotificationsData,
|
||||||
acting_user_id: int,
|
acting_user_id: int,
|
||||||
message_id: int,
|
message_id: int,
|
||||||
private_message: bool,
|
private_message: bool,
|
||||||
@@ -807,9 +807,9 @@ def maybe_enqueue_notifications(
|
|||||||
"""
|
"""
|
||||||
notified: Dict[str, bool] = {}
|
notified: Dict[str, bool] = {}
|
||||||
|
|
||||||
if user_data.is_push_notifiable(private_message, acting_user_id, idle):
|
if user_notifications_data.is_push_notifiable(private_message, acting_user_id, idle):
|
||||||
notice = build_offline_notification(user_data.user_id, message_id)
|
notice = build_offline_notification(user_notifications_data.user_id, message_id)
|
||||||
notice["trigger"] = user_data.get_push_notification_trigger(
|
notice["trigger"] = user_notifications_data.get_push_notification_trigger(
|
||||||
private_message, acting_user_id, idle
|
private_message, acting_user_id, idle
|
||||||
)
|
)
|
||||||
notice["stream_name"] = stream_name
|
notice["stream_name"] = stream_name
|
||||||
@@ -821,9 +821,9 @@ def maybe_enqueue_notifications(
|
|||||||
# mention. Eventually, we'll add settings to allow email
|
# mention. Eventually, we'll add settings to allow email
|
||||||
# notifications to match the model of push notifications
|
# notifications to match the model of push notifications
|
||||||
# above.
|
# above.
|
||||||
if user_data.is_email_notifiable(private_message, acting_user_id, idle):
|
if user_notifications_data.is_email_notifiable(private_message, acting_user_id, idle):
|
||||||
notice = build_offline_notification(user_data.user_id, message_id)
|
notice = build_offline_notification(user_notifications_data.user_id, message_id)
|
||||||
notice["trigger"] = user_data.get_email_notification_trigger(
|
notice["trigger"] = user_notifications_data.get_email_notification_trigger(
|
||||||
private_message, acting_user_id, idle
|
private_message, acting_user_id, idle
|
||||||
)
|
)
|
||||||
notice["stream_name"] = stream_name
|
notice["stream_name"] = stream_name
|
||||||
@@ -963,7 +963,7 @@ def process_message_event(
|
|||||||
|
|
||||||
extra_user_data[user_profile_id]["internal_data"].update(
|
extra_user_data[user_profile_id]["internal_data"].update(
|
||||||
maybe_enqueue_notifications(
|
maybe_enqueue_notifications(
|
||||||
user_data=user_notifications_data,
|
user_notifications_data=user_notifications_data,
|
||||||
acting_user_id=sender_id,
|
acting_user_id=sender_id,
|
||||||
message_id=message_id,
|
message_id=message_id,
|
||||||
private_message=private_message,
|
private_message=private_message,
|
||||||
@@ -1131,7 +1131,7 @@ def process_message_update_event(
|
|||||||
)
|
)
|
||||||
|
|
||||||
maybe_enqueue_notifications_for_message_update(
|
maybe_enqueue_notifications_for_message_update(
|
||||||
user_data=user_notifications_data,
|
user_notifications_data=user_notifications_data,
|
||||||
message_id=message_id,
|
message_id=message_id,
|
||||||
acting_user_id=acting_user_id,
|
acting_user_id=acting_user_id,
|
||||||
private_message=(stream_name is None),
|
private_message=(stream_name is None),
|
||||||
@@ -1148,7 +1148,7 @@ def process_message_update_event(
|
|||||||
|
|
||||||
|
|
||||||
def maybe_enqueue_notifications_for_message_update(
|
def maybe_enqueue_notifications_for_message_update(
|
||||||
user_data: UserMessageNotificationsData,
|
user_notifications_data: UserMessageNotificationsData,
|
||||||
message_id: int,
|
message_id: int,
|
||||||
acting_user_id: int,
|
acting_user_id: int,
|
||||||
private_message: bool,
|
private_message: bool,
|
||||||
@@ -1156,7 +1156,7 @@ def maybe_enqueue_notifications_for_message_update(
|
|||||||
presence_idle: bool,
|
presence_idle: bool,
|
||||||
prior_mentioned: bool,
|
prior_mentioned: bool,
|
||||||
) -> None:
|
) -> None:
|
||||||
if user_data.sender_is_muted:
|
if user_notifications_data.sender_is_muted:
|
||||||
# Never send notifications if the sender has been muted
|
# Never send notifications if the sender has been muted
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -1181,7 +1181,7 @@ def maybe_enqueue_notifications_for_message_update(
|
|||||||
# without extending the UserMessage data model.
|
# without extending the UserMessage data model.
|
||||||
return
|
return
|
||||||
|
|
||||||
if user_data.stream_push_notify or user_data.stream_email_notify:
|
if user_notifications_data.stream_push_notify or user_notifications_data.stream_email_notify:
|
||||||
# Currently we assume that if this flag is set to True, then
|
# Currently we assume that if this flag is set to True, then
|
||||||
# the user already was notified about the earlier message,
|
# the user already was notified about the earlier message,
|
||||||
# so we short circuit. We may handle this more rigorously
|
# so we short circuit. We may handle this more rigorously
|
||||||
@@ -1189,10 +1189,10 @@ def maybe_enqueue_notifications_for_message_update(
|
|||||||
# model.
|
# model.
|
||||||
return
|
return
|
||||||
|
|
||||||
idle = presence_idle or receiver_is_off_zulip(user_data.user_id)
|
idle = presence_idle or receiver_is_off_zulip(user_notifications_data.user_id)
|
||||||
|
|
||||||
maybe_enqueue_notifications(
|
maybe_enqueue_notifications(
|
||||||
user_data=user_data,
|
user_notifications_data=user_notifications_data,
|
||||||
message_id=message_id,
|
message_id=message_id,
|
||||||
acting_user_id=acting_user_id,
|
acting_user_id=acting_user_id,
|
||||||
private_message=private_message,
|
private_message=private_message,
|
||||||
|
|||||||
Reference in New Issue
Block a user