Zimin A.N.
|
74704dbf5b
|
feat(notifications): Phase C — Don't Disturb (quiet hours window)
User задаёт quiet window (e.g. 22:00–08:00 Europe/Moscow) — external
channels (email + express) DROP'аются dispatcher'ом. In-app bell badge
остаётся (юзер видит при следующем визите UI). Cross-midnight aware.
## Backend
- Migration 0026: user_notification_settings table (user_id PK + quiet_hours_start/end LocalTime + tz)
- Entity UserNotificationSettings + Repository (stock CRUD)
- UserPreferencesGate extended:
- Constructor takes settingsRepo
- allows() checks isQuiet(userId) первым for external channels (EMAIL/EXPRESS/TELEGRAM)
- isQuiet: load settings → if hasEffectiveQuietHours() → check current LocalTime в user's TZ
- inWindow() helper: cross-midnight semantics (22:00–08:00 wraps midnight)
- Invalid TZ → fallback к DEFAULT_TZ (Europe/Moscow) с WARN log
- Test seam: setClockForTesting(Clock) для deterministic tests
- MeNotificationsSettingsController: GET/PUT /api/v1/me/notifications/settings
- HH:mm input parsing, IANA TZ validation, enabled=false clears window
- Auth required (JWT sub claim)
## Frontend
- NotificationSettings type в client.ts
- useMyNotificationSettings query (60s stale)
- useUpdateNotificationSettings mutation
- QuietHoursSection в /me/notifications/preferences route:
- Switch toggle + 2 time inputs + TZ select (12 RU/UTC zones)
- Optimistic local state synced from query
- Save button с pending/success/error states
- i18n RU + EN
## Tests
- 9 new tests UserPreferencesGateQuietHoursTest:
- Same-day window match (inclusive start, exclusive end)
- Cross-midnight window match (22:00–08:00)
- No settings row → не блокирует
- Quiet window active → email + express dropped
- Outside window → email allowed
- start == end → disabled (zero-duration treated as off)
- Reviewer pool bypasses (always ON)
- Invalid TZ → fallback default
- Specific pref ON + quiet ON → quiet wins (drop)
- NotificationsDispatcherTest constructor updated к new signature
- Total notifications tests: 53 → 62, все green
## Design rationale (drop vs defer)
Drop chosen за defer (queue + re-fire scheduler) потому что:
- Defer needs persistent queue + scheduled retry — high complexity
- Most notifications time-relevant (draft N hours ago less actionable)
- Bell badge показывает full feed — ничего не «теряется»
- Phase D summary digest можно build later если demand surfaces
|
2026-05-17 11:11:21 +03:00 |
|
Александр Зимин
|
f04b1be1f6
|
feat(notifications): Phase B-2 — per-event-type granular preferences
|
2026-05-15 16:53:32 +00:00 |
|
Александр Зимин
|
9f885e50c2
|
fix(notifications): dispatcher race с OutboxPoller — emails never sent
|
2026-05-15 15:34:36 +00:00 |
|
Александр Зимин
|
9452adaf55
|
feat(notifications): Phase B backend — per-user channel preferences
|
2026-05-15 14:56:25 +00:00 |
|
Александр Зимин
|
fb7fd51c49
|
fix(notifications): EmailChannel @Bean registration вместо @Component (race fix)
|
2026-05-15 12:40:39 +00:00 |
|
Александр Зимин
|
844cab78ae
|
fix(notifications): WARN when dispatcher init с zero channels
|
2026-05-15 07:01:40 +00:00 |
|
Александр Зимин
|
9050e2427e
|
feat(notifications): TODO 7 — draft decision toast + email + bell badge
|
2026-05-14 14:40:35 +00:00 |
|
Александр Зимин
|
3b7b1bffe5
|
feat(notifications): Phase A foundation — module + schema 0021
|
2026-05-10 15:41:34 +00:00 |
|