Add mentions, pin messages and conversations, and search within chats

This commit is contained in:
2026-09-30 10:40:29 +03:30
parent 7c4b24fad6
commit f71e78f3a7
9 changed files with 1152 additions and 31 deletions
@@ -0,0 +1,42 @@
-- CreateTable
CREATE TABLE "ConversationPinnedMessage" (
"id" TEXT NOT NULL,
"organizationId" TEXT NOT NULL,
"externalRoomId" TEXT NOT NULL,
"messageId" TEXT NOT NULL,
"preview" TEXT NOT NULL DEFAULT '',
"pinnedByUserId" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "ConversationPinnedMessage_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "ConversationRoomUserPin" (
"id" TEXT NOT NULL,
"organizationId" TEXT NOT NULL,
"userId" TEXT NOT NULL,
"externalRoomId" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "ConversationRoomUserPin_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "ConversationPinnedMessage_organizationId_externalRoomId_key" ON "ConversationPinnedMessage"("organizationId", "externalRoomId");
-- CreateIndex
CREATE INDEX "ConversationPinnedMessage_organizationId_externalRoomId_idx" ON "ConversationPinnedMessage"("organizationId", "externalRoomId");
-- CreateIndex
CREATE UNIQUE INDEX "ConversationRoomUserPin_organizationId_userId_externalRoomId_key" ON "ConversationRoomUserPin"("organizationId", "userId", "externalRoomId");
-- CreateIndex
CREATE INDEX "ConversationRoomUserPin_organizationId_userId_idx" ON "ConversationRoomUserPin"("organizationId", "userId");
-- AddForeignKey
ALTER TABLE "ConversationPinnedMessage" ADD CONSTRAINT "ConversationPinnedMessage_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "ConversationRoomUserPin" ADD CONSTRAINT "ConversationRoomUserPin_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE;
+31
View File
@@ -210,6 +210,8 @@ model Organization {
conversationSettings ConversationSettings?
conversationRooms ConversationRoom[]
conversationHiddenMessages ConversationHiddenMessage[]
conversationPinnedMessages ConversationPinnedMessage[]
conversationRoomUserPins ConversationRoomUserPin[]
}
model User {
@@ -2113,3 +2115,32 @@ model ConversationHiddenMessage {
@@unique([organizationId, externalRoomId, messageId, scope, hiddenByUserId])
@@index([organizationId, externalRoomId])
}
/// یک پیام سنجاق‌شده در هر اتاق (برای همه اعضا)
model ConversationPinnedMessage {
id String @id @default(cuid())
organizationId String
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
externalRoomId String
messageId String
preview String @default("")
pinnedByUserId String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@unique([organizationId, externalRoomId])
@@index([organizationId, externalRoomId])
}
/// سنجاق گفتگو در لیست — فقط برای همان کاربر
model ConversationRoomUserPin {
id String @id @default(cuid())
organizationId String
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
userId String
externalRoomId String
createdAt DateTime @default(now())
@@unique([organizationId, userId, externalRoomId])
@@index([organizationId, userId])
}