feat(notifications): include federated chat messages and invitations

This commit is contained in:
2026-10-15 17:50:38 +02:00
parent 697f538b6e
commit 7b61857fb8
11 changed files with 413 additions and 16 deletions

View File

@@ -0,0 +1,7 @@
INSERT INTO notifications_event_types (event_key, display_name, description, category, allowed_channels) VALUES
('collaboration.message.new', 'Zusammenarbeit: Chatnachrichten', 'Neue Nachrichten in freigegebenen Unterräumen und föderierten Chats.', 'collaboration', '["inapp","email","push"]'),
('collaboration.room.invited', 'Zusammenarbeit: Einladungen', 'Persönliche Einladungen in freigegebene Unterräume und föderierte Chats.', 'collaboration', '["inapp","email","push"]')
ON CONFLICT (event_key) DO NOTHING;
--> statement-breakpoint
CREATE INDEX notifications_collaboration_queued ON notifications_items(created_at)
WHERE status='queued' AND event_type IN ('collaboration.message.new','collaboration.room.invited');

View File

@@ -561,6 +561,13 @@
"when": 1792022400000,
"tag": "0082_archive_users",
"breakpoints": true
},
{
"idx": 80,
"version": "7",
"when": 1792022400001,
"tag": "0083_collaboration_notifications",
"breakpoints": true
}
]
}

View File

@@ -5,7 +5,9 @@ import {
text,
jsonb,
timestamp,
index,
} from "drizzle-orm/pg-core"
import { sql } from "drizzle-orm"
import { tenants } from "./tenants"
import { authUsers } from "./auth_users"
@@ -48,7 +50,8 @@ export const notificationsItems = pgTable("notifications_items", {
sentAt: timestamp("sent_at", { withTimezone: true }),
readAt: timestamp("read_at", { withTimezone: true }),
})
}, t => ({ collaborationQueued: index("notifications_collaboration_queued").on(t.createdAt)
.where(sql`${t.status}='queued' AND ${t.eventType} IN ('collaboration.message.new','collaboration.room.invited')`) }))
export type NotificationItem = typeof notificationsItems.$inferSelect
export type NewNotificationItem = typeof notificationsItems.$inferInsert