feat(notifications): Phase B-2 — per-event-type granular preferences

This commit is contained in:
Александр Зимин
2026-05-15 16:53:32 +00:00
parent b5c9d07403
commit f04b1be1f6
11 changed files with 420 additions and 175 deletions
+29 -7
View File
@@ -721,16 +721,38 @@ export type NotificationsResponse = {
}
/**
* Phase B — per-channel notification opt-in/out для current user. Backend
* endpoint: GET/PUT /api/v1/me/notifications/preferences. Default semantics
* (server-side, when row missing): email=true, express=false, telegram=false.
* Phase B-2 — per-(eventType, channel) notification opt-in/out для current
* user. Backend endpoint: GET/PUT /api/v1/me/notifications/preferences.
*
* <p>Express/Telegram channels пока not wired backend-side — toggles в UI
* disabled с tooltip 'Скоро'. Email — единственный фактически работающий
* канал в Phase A/B.
* <p>Matrix shape: 4 known event types × 3 channels = 12 toggles. User может
* opt-out 'Submitted via email' (queue noise) keep 'Approved via email'
* (action confirmation).
*
* <p>Defaults (server-side, для missing rows):
* email=true, express=false, telegram=false.
*
* <p>Resolution для каждой ячейки: specific row → wildcard '*' (Phase B
* compat) → default policy.
*
* <p>Express/Telegram channels не wired backend-side — toggles в UI disabled.
*/
export type NotificationPreferences = {
export type ChannelToggles = {
email: boolean
express: boolean
telegram: boolean
}
/** Map keyed по event type. Backend сейчас возвращает 4 known events. */
export type NotificationPreferences = Record<string, ChannelToggles>
/**
* Canonical event types — должны совпадать с backend
* MeNotificationsPreferencesController.KNOWN_EVENT_TYPES.
*/
export const NOTIFICATION_EVENT_TYPES = [
'RecordDraftSubmitted',
'RecordDraftApproved',
'RecordDraftRejected',
'RecordDraftWithdrawn',
] as const
export type NotificationEventType = (typeof NOTIFICATION_EVENT_TYPES)[number]