Skip to main content

Module notification_pref

Module notification_pref 

Source
Expand description

Per-user notification preferences.

Editors opt out of categories of notifications they don’t want to receive. Every fire-site (workflow_mail, page_subscription, comment replies) checks is_enabled before delivering so the mailer doesn’t burn cycles building emails for unsubscribed users.

Missing rows are treated as enabled — first-touch users get every notification until they explicitly disable a category. This matches the principle of least surprise: a new editor hears about everything, then trims.

Structs§

NotificationPref

Constants§

ALL_KINDS
The full canonical list — rendered in order on the preferences page. (label, kind, hint) for each row.
COMMENT_REPLIED
COMMENT_RESOLVED
PAGE_PUBLISHED_SUBSCRIBED
WORKFLOW_APPROVED
WORKFLOW_REJECTED
WORKFLOW_SUBMITTED
Every category an editor can mute. String keys (not an enum) because the set is editor-facing and host plugins may register their own kinds via the same table.

Functions§

filter_enabled
Filter user_ids to those who haven’t opted out of kind. Missing rows are kept (default = enabled). Used at fan-out sites to skip email composition for muted users.
is_enabled
Whether user_id wants to receive notifications of kind. A missing row is treated as true — opt-out semantics.
map_for_user
Every preference row for a user, keyed by kind.
pref_kind_for_workflow_event
Map a workflow event name to the preference kind a recipient uses to mute it. Centralised so the routing stays consistent across every workflow notification call site.
set_enabled
Upsert the toggle for (user_id, kind).