Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
docs: Update developer documentation for notification_data.py.
Abhijeet Prasad Bodas678526881bce
diff --git a/docs/subsystems/notifications.md b/docs/subsystems/notifications.mdindex f3a290cc23c..640826f49f7 100644--- a/docs/subsystems/notifications.md+++ b/docs/subsystems/notifications.md@@ -33,10 +33,9 @@ as follows:`send_event` for each user receiving the message.* Data about user configuration relevant to the message, such as`online_push_user_ids` and `stream_notify_user_ids`, are included- alongside `flags` in the per-user data structure.+ in the main event dictionary.* The `presence_idle_user_ids` set, containing the subset of- recipient users who are mentioned, are PM recipients, have alert- words, or otherwise would normally get a notification, but have not+ recipient users who can potentially receive notifications, but have notinteracted with a Zulip client in the last few minutes. (Users whohave generally will not receive a notification unless the`enable_online_push_notifications` flag is enabled). This data@@ -63,9 +62,11 @@ as follows:* However, that check does not handle the hard disconnect problem:if a user was present 1 minute before a message was sent, and thenclosed their laptop, the user will not be in- `presence_idle_user_ids`, and so without an additional mechanism,- messages sent shortly after a user leaves would never trigger a- notification (!).+ `presence_idle_user_ids` (because it takes a+ [few minutes](../subsystems/presence.md) of being idle for Zulip+ clients to declare to the server that the user is actually idle),+ and so without an additional mechanism, messages sent shortly after+ a user leaves would never trigger a notification (!).* We solve that problem by also notifying if`receiver_is_off_zulip` returns `True`, which checks whether the user has anycurrent events system clients registered to receive `message`@@ -78,11 +79,15 @@ as follows:one; this second check solves the hard disconnect problem, resulting innotifications for these hard-disconnect cases usually coming 10minutes late.+ * We try to contain the "when to notify" business logic in the+ `zerver/lib/notification_data.py` class methods. The module has+ unit tests for all possible situations in+ `test_notification_data.py`.* The message-edit code path has parallel logic in`maybe_enqueue_notifications_for_message_update` for triggeringnotifications in cases like a mention added during messageediting.- * The business logic for all these notification decisions made+ * The notification sending logic for message editsinside Tornado has extensive automated test suites; e.g.`test_message_edit_notifications.py` covers all the cases aroundediting a message to add/remove a mention.diff --git a/docs/subsystems/sending-messages.md b/docs/subsystems/sending-messages.mdindex ed831c2a5a7..4073e9f9a60 100644--- a/docs/subsystems/sending-messages.md+++ b/docs/subsystems/sending-messages.md@@ -59,8 +59,8 @@ number of purposes:to just do the check for whether a notification should begenerated, and then put an event into an appropriate[queue](../subsystems/queuing.md) to actually send the message.- See `maybe_enqueue_notifications` and related code for this part- of the logic.+ See `maybe_enqueue_notifications` and `zerver/lib/notification_data.py` for+ this part of the logic.* Splicing user-dependent data (E.g. `flags` such as when the userwas `mentioned`) into the events.* Handling the [local echo details](#local-echo).