Public context for notification preference management.
Preferences are keyed by (recipient_id, notification_key, channel).
recipient_id is the same string as recipient_identity on notification rows.
Missing preferences default to enabled — channels are opt-in by default.
Summary
Functions
Returns true if the category is enabled for the recipient — defaults to true when no preference row exists (opt-in default).
Returns true if the channel is enabled for the recipient/key — defaults to true when no preference row exists (opt-in default).
Fetches the category preference row for the given recipient/category, or nil.
Fetches the preference row for the given recipient/key/channel, or nil.
Upserts a category preference. On conflict, updates :enabled and :updated_at.
Upserts a preference. On conflict, updates :enabled and :updated_at.
Functions
Returns true if the category is enabled for the recipient — defaults to true when no preference row exists (opt-in default).
Returns true if the channel is enabled for the recipient/key — defaults to true when no preference row exists (opt-in default).
@spec get_category_preference(String.t(), String.t()) :: Chimeway.Preferences.CategoryPreference.t() | nil
Fetches the category preference row for the given recipient/category, or nil.
@spec get_preference(String.t(), String.t(), String.t()) :: Chimeway.Preferences.NotificationPreference.t() | nil
Fetches the preference row for the given recipient/key/channel, or nil.
@spec upsert_category_preference(map()) :: {:ok, Chimeway.Preferences.CategoryPreference.t()} | {:error, Ecto.Changeset.t()}
Upserts a category preference. On conflict, updates :enabled and :updated_at.
@spec upsert_preference(map()) :: {:ok, Chimeway.Preferences.NotificationPreference.t()} | {:error, Ecto.Changeset.t()}
Upserts a preference. On conflict, updates :enabled and :updated_at.