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.

event_queue: Pass `bool`s to `maybe_enqueue_for_message_update`.

Abhijeet Prasad Bodas5f5323be7d73
diff --git a/zerver/tornado/event_queue.py b/zerver/tornado/event_queue.py
index 26a3d322692..b8a2ad41b80 100644
--- a/zerver/tornado/event_queue.py
+++ b/zerver/tornado/event_queue.py
@@ -1140,14 +1140,14 @@ def process_message_update_event(
user_profile_id=user_profile_id,
message_id=message_id,
private_message=(stream_name is None),
- mention_user_ids=mention_user_ids,
+ mentioned=(user_profile_id in mention_user_ids),
wildcard_mention_notify=wildcard_mention_notify,
- stream_push_user_ids=stream_push_user_ids,
- stream_email_user_ids=stream_email_user_ids,
+ stream_push_notify=(user_profile_id in stream_push_user_ids),
+ stream_email_notify=(user_profile_id in stream_email_user_ids),
stream_name=stream_name,
- online_push_user_ids=online_push_user_ids,
- presence_idle_user_ids=presence_idle_user_ids,
- prior_mention_user_ids=prior_mention_user_ids,
+ online_push_enabled=(user_profile_id in online_push_user_ids),
+ presence_idle=(user_profile_id in presence_idle_user_ids),
+ prior_mentioned=(user_profile_id in prior_mention_user_ids),
)
for client in get_client_descriptors_for_user(user_profile_id):
@@ -1161,21 +1161,21 @@ def maybe_enqueue_notifications_for_message_update(
user_profile_id: UserProfile,
message_id: int,
private_message: bool,
- mention_user_ids: Set[int],
+ mentioned: bool,
wildcard_mention_notify: bool,
- stream_push_user_ids: Set[int],
- stream_email_user_ids: Set[int],
+ stream_push_notify: bool,
+ stream_email_notify: bool,
stream_name: Optional[str],
- online_push_user_ids: Set[int],
- presence_idle_user_ids: Set[int],
- prior_mention_user_ids: Set[int],
+ online_push_enabled: bool,
+ presence_idle: bool,
+ prior_mentioned: bool,
) -> None:
if private_message:
# We don't do offline notifications for PMs, because
# we already notified the user of the original message
return
- if user_profile_id in prior_mention_user_ids:
+ if prior_mentioned:
# Don't spam people with duplicate mentions. This is
# especially important considering that most message
# edits are simple typo corrections.
@@ -1191,9 +1191,6 @@ def maybe_enqueue_notifications_for_message_update(
# without extending the UserMessage data model.
return
- stream_push_notify = user_profile_id in stream_push_user_ids
- stream_email_notify = user_profile_id in stream_email_user_ids
-
if stream_push_notify or stream_email_notify:
# Currently we assume that if this flag is set to True, then
# the user already was notified about the earlier message,
@@ -1202,12 +1199,7 @@ def maybe_enqueue_notifications_for_message_update(
# model.
return
- # We can have newly mentioned people in an updated message.
- mentioned = user_profile_id in mention_user_ids
-
- online_push_enabled = user_profile_id in online_push_user_ids
-
- idle = (user_profile_id in presence_idle_user_ids) or receiver_is_off_zulip(user_profile_id)
+ idle = presence_idle or receiver_is_off_zulip(user_profile_id)
maybe_enqueue_notifications(
user_profile_id=user_profile_id,