feat(server): notification system (#10053)

closes CLOUD-52
This commit is contained in:
fengmk2
2025-03-06 15:25:05 +00:00
parent 81694a1144
commit 7302c4f954
20 changed files with 2356 additions and 14 deletions

View File

@@ -35,6 +35,8 @@ model User {
updatedSnapshot Snapshot[] @relation("updatedSnapshot")
createdUpdate Update[] @relation("createdUpdate")
createdHistory SnapshotHistory[] @relation("createdHistory")
// receive notifications
notifications Notification[] @relation("user_notifications")
@@index([email])
@@map("users")
@@ -624,3 +626,39 @@ model Blob {
@@id([workspaceId, key])
@@map("blobs")
}
enum NotificationType {
Mention
Invitation
InvitationAccepted
InvitationBlocked
InvitationRejected
}
enum NotificationLevel {
// Makes a sound and appears as a heads-up notification
High
// Makes a sound
Default
// Makes no sound
Low
Min
None
}
model Notification {
id String @id @default(uuid()) @db.VarChar
userId String @map("user_id") @db.VarChar
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(3)
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(3)
level NotificationLevel
read Boolean @default(false)
type NotificationType
body Json @db.JsonB
user User @relation(name: "user_notifications", fields: [userId], references: [id], onDelete: Cascade)
// for user notifications list, including read and unread, ordered by createdAt
@@index([userId, createdAt, read])
@@map("notifications")
}