Add internal org chat (phase 1) with DM, groups, and org settings.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-29 10:34:01 +03:30
co-authored by Cursor
parent 589c763ef8
commit a1655432fc
21 changed files with 1912 additions and 8 deletions
+35
View File
@@ -207,6 +207,8 @@ model Organization {
leadStages LeadStage[]
leadEvents LeadEvent[]
leadImportJobs LeadImportJob[]
conversationSettings ConversationSettings?
conversationRooms ConversationRoom[]
}
model User {
@@ -2060,3 +2062,36 @@ model LeadImportJob {
@@index([organizationId, status, createdAt])
@@index([status, createdAt])
}
/// تنظیمات اتصال به سرویس گفتگوی خارجی (هر محیط CRM)
model ConversationSettings {
organizationId String @id
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
chatHost String
apiKeyCipher String
apiKeyIv String
apiKeyTag String
uploadUrl String @default("")
downloadUrl String @default("")
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
/// نگاشت roomهای سرویس چت (DM dedup و گروه‌های ساخته‌شده از CRM)
model ConversationRoom {
id String @id @default(cuid())
organizationId String
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
externalRoomId String
kind String
name String?
dmUserMinId String?
dmUserMaxId String?
createdByUserId String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@unique([organizationId, externalRoomId])
@@unique([organizationId, dmUserMinId, dmUserMaxId])
@@index([organizationId, kind])
}