mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-22 21:11:14 +00:00
feat(notifications): admin defaults for users, and channels blocked for everyone
Admin > Notifications gets a Defaults for users matrix: each event and channel starts On, Off (a user may still turn it on) or Blocked (off for everyone). A user's own choice is kept against the default, and a value equal to it is stored as no row, so a later change of the default reaches everyone who never chose. Blocked cells show as locked in the user settings on desktop and phone, and the server ignores any attempt to turn one on. (#1536)
This commit is contained in:
@@ -135,6 +135,20 @@ export type AdminCollabFeaturesRequest = z.infer<typeof adminCollabFeaturesReque
|
||||
export const adminNotificationPreferencesRequestSchema = z.record(z.string(), z.record(z.string(), z.boolean()));
|
||||
export type AdminNotificationPreferencesRequest = z.infer<typeof adminNotificationPreferencesRequestSchema>;
|
||||
|
||||
/**
|
||||
* What a user's notification cell starts as, set by the admin for the whole
|
||||
* instance (#1536): `on` (the default), `off` (the user may still turn it on)
|
||||
* or `blocked` (off for everyone, and the user cannot turn it on).
|
||||
*/
|
||||
export const NOTIFICATION_DEFAULTS = ['on', 'off', 'blocked'] as const;
|
||||
export type NotificationDefault = (typeof NOTIFICATION_DEFAULTS)[number];
|
||||
|
||||
/** PUT /api/admin/notification-preferences/defaults: event → channel → default. Cells left out keep theirs. */
|
||||
export const notificationDefaultsUpdateRequestSchema = z.object({
|
||||
defaults: z.record(z.string().max(64), z.record(z.string().max(64), z.enum(NOTIFICATION_DEFAULTS))),
|
||||
});
|
||||
export type NotificationDefaultsUpdateRequest = z.infer<typeof notificationDefaultsUpdateRequestSchema>;
|
||||
|
||||
// Heterogeneous values, and `null` is meaningful — SettingsService treats it as
|
||||
// "reset to the built-in default". z.record also rejects arrays and null bodies,
|
||||
// preserving the route's object-only guard.
|
||||
|
||||
Reference in New Issue
Block a user