/
PostmenBlake
/
NotificationPreferencesService
Обзор
Документация
Войти
/
PostmenBlake
/
NotificationPreferencesService
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/domain/entities/UserPreferences.ts
40 строк
1 KB
kurava
feat: initial commit - Notification Preferences Service
17 июн 2026, 09:11
17 июн 2026, 09:11
48825c3
Код
Авторство
О чём код?
import { NotificationType, Channel, QuietHours } from '../types/notification'; export class UserPreferences { constructor( public readonly userId: string, private preferences: Map< string, { enabled: boolean; quietHours?: QuietHours | null } >, ) {} getPreference( notificationType: NotificationType, channel: Channel, ): { enabled: boolean; quietHours?: QuietHours | null } | undefined { const key = this.getKey(notificationType, channel); return this.preferences.get(key); } setPreference( notificationType: NotificationType, channel: Channel, enabled: boolean, quietHours?: QuietHours | null, ): void { const key = this.getKey(notificationType, channel); this.preferences.set(key, { enabled, quietHours: quietHours || null }); } getAllPreferences(): Map< string, { enabled: boolean; quietHours?: QuietHours | null } > { return new Map(this.preferences); } private getKey(notificationType: NotificationType, channel: Channel): string { return `${notificationType}:${channel}`; } }