Notification Preference
Data Entity
Description
Per-user configuration record storing granular notification channel and scenario opt-in/opt-out settings, enabling fine-grained control over push, email, and SMS delivery across all notification scenarios.
Data Structure
| Name | Type | Description | Constraints |
|---|---|---|---|
id |
uuid |
Primary key | PKrequiredunique |
user_id |
uuid |
Foreign key to users table — one preference record per user | requiredunique |
push_enabled |
boolean |
Master toggle for all push notification delivery to this user | required |
email_enabled |
boolean |
Master toggle for all email notification delivery to this user | required |
sms_enabled |
boolean |
Master toggle for all SMS notification delivery to this user | required |
scenario_overrides |
json |
Per-scenario channel overrides as a map of scenario_id → {push, email, sms} booleans. Null means inherit the master toggle. Example: {"assignment-dispatched": {"push": true, "email": false}} | - |
quiet_hours_enabled |
boolean |
Whether the user has configured a quiet hours window during which push notifications are suppressed | required |
quiet_hours_start |
string |
Local time (HH:MM 24h) at which quiet hours begin. Null if quiet_hours_enabled is false. | - |
quiet_hours_end |
string |
Local time (HH:MM 24h) at which quiet hours end. Null if quiet_hours_enabled is false. | - |
timezone |
string |
IANA timezone identifier used to evaluate quiet_hours (e.g. 'Europe/Oslo'). Defaults to 'Europe/Oslo'. | required |
digest_frequency |
enum |
How often to bundle low-priority notifications into a digest email instead of sending individually | required |
language_override |
string |
BCP-47 language tag for notification content. Null means use the platform default for the user's organization. | - |
created_at |
datetime |
Record creation timestamp (UTC) | required |
updated_at |
datetime |
Last modification timestamp (UTC), updated on every write | required |
Database Indexes
idx_notification_preferences_user_id
Columns: user_id
idx_notification_preferences_updated_at
Columns: updated_at
Validation Rules
valid_quiet_hours_format
error
Validation failed
valid_timezone
error
Validation failed
valid_scenario_override_keys
warning
Validation failed
valid_language_override
error
Validation failed
user_id_exists
error
Validation failed
Business Rules
one_record_per_user
Each user has exactly one notification_preferences record. Creation uses upsert semantics — if a record already exists for the user_id, update it rather than inserting a duplicate.
master_toggle_overrides_scenario
If push_enabled / email_enabled / sms_enabled is false, no notification of that channel type is delivered regardless of scenario_overrides values. Channel master toggles are the final gate.
quiet_hours_requires_times
If quiet_hours_enabled is true, both quiet_hours_start and quiet_hours_end must be present and must differ. Enabling quiet hours without both times is rejected.
auto_create_on_registration
When a new user account is created, a notification_preferences record is auto-created with platform defaults (push on, email on, sms off, digest immediate, timezone Europe/Oslo). Users should never be without a preferences record.
offline_sync_support
Preference reads are cached in the local Drift database so that notification decisions (e.g. quiet hours) can be evaluated offline. Writes are queued in the mutation outbox and synced when connectivity returns.