feat(notifications): add per-tenant notification preferences
This commit is contained in:
19
backend/db/migrations/0079_notification_matrix.sql
Normal file
19
backend/db/migrations/0079_notification_matrix.sql
Normal file
@@ -0,0 +1,19 @@
|
||||
INSERT INTO notifications_event_types (event_key, display_name, description, category, allowed_channels) VALUES
|
||||
('communication.message.direct', 'Direktnachrichten', 'Neue persönliche Chatnachrichten.', 'communication', '["inapp","email","push"]'),
|
||||
('communication.message.mentioned', 'Erwähnungen', 'Du wirst in einem Chatraum oder Projektchat persönlich erwähnt.', 'communication', '["inapp","email","push"]'),
|
||||
('communication.message.room', 'Raum- und Projektnachrichten', 'Neue Nachrichten in deinen Chaträumen, ohne persönliche Erwähnung.', 'communication', '["inapp","email","push"]')
|
||||
ON CONFLICT (event_key) DO NOTHING;
|
||||
--> statement-breakpoint
|
||||
UPDATE notifications_event_types SET allowed_channels = '["inapp","email","push"]', display_name = 'Neuer Chatraum', description = 'Du wirst einem neu angelegten Chatraum hinzugefügt.' WHERE event_key = 'communication.room.invited';
|
||||
--> statement-breakpoint
|
||||
INSERT INTO notifications_preferences (tenant_id, user_id, event_type, channel, enabled)
|
||||
SELECT tenant_id, user_id, replacement.key, channel, enabled FROM notifications_preferences
|
||||
CROSS JOIN (VALUES ('communication.message.direct'), ('communication.message.mentioned')) AS replacement(key)
|
||||
WHERE event_type = 'communication.message.new' ON CONFLICT DO NOTHING;
|
||||
--> statement-breakpoint
|
||||
INSERT INTO notifications_preferences_defaults (tenant_id, event_key, channel, enabled)
|
||||
SELECT tenant_id, replacement.key, channel, enabled FROM notifications_preferences_defaults
|
||||
CROSS JOIN (VALUES ('communication.message.direct'), ('communication.message.mentioned')) AS replacement(key)
|
||||
WHERE event_key = 'communication.message.new' ON CONFLICT DO NOTHING;
|
||||
--> statement-breakpoint
|
||||
UPDATE notifications_event_types SET is_active = false WHERE event_key IN ('communication.message.new', 'communication.call.started', 'communication.call.missed');
|
||||
Reference in New Issue
Block a user