feat: implement message CRUD and dark mode

- Add Message, Recipient models and migration
- Create message API routes (GET, POST, PATCH, DELETE)
- Fix IDOR vulnerability in PATCH (verify ownership before delete)
- Add dashboard and message pages (list, new, detail)
- Add UI components (card, input, label, textarea)
- Enable dark mode in layout
- Add session user id typing to NextAuth
- Add AGENTS.md memory bank documentation
This commit is contained in:
Yusuf İpek
2025-12-24 15:07:20 +03:00
parent c2da0437d0
commit 1626106a8b
17 changed files with 851 additions and 3 deletions
@@ -0,0 +1,42 @@
-- CreateTable
CREATE TABLE "Message" (
"id" TEXT NOT NULL,
"userId" TEXT NOT NULL,
"title" TEXT NOT NULL,
"content" TEXT,
"status" TEXT NOT NULL DEFAULT 'DRAFT',
"lastPing" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"checkInterval" INTEGER NOT NULL DEFAULT 24,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "Message_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "Recipient" (
"id" TEXT NOT NULL,
"messageId" TEXT NOT NULL,
"email" TEXT NOT NULL,
CONSTRAINT "Recipient_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "Attachment" (
"id" TEXT NOT NULL,
"messageId" TEXT NOT NULL,
"fileUrl" TEXT NOT NULL,
"fileName" TEXT NOT NULL,
CONSTRAINT "Attachment_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "Message" ADD CONSTRAINT "Message_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Recipient" ADD CONSTRAINT "Recipient_messageId_fkey" FOREIGN KEY ("messageId") REFERENCES "Message"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Attachment" ADD CONSTRAINT "Attachment_messageId_fkey" FOREIGN KEY ("messageId") REFERENCES "Message"("id") ON DELETE CASCADE ON UPDATE CASCADE;
+31 -1
View File
@@ -1,4 +1,3 @@
// ... existing code ...
generator client {
provider = "prisma-client-js"
}
@@ -42,6 +41,37 @@ model User {
image String?
accounts Account[]
sessions Session[]
messages Message[]
}
model Message {
id String @id @default(cuid())
userId String
title String
content String? @db.Text
status String @default("DRAFT")
lastPing DateTime @default(now())
checkInterval Int @default(24)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
recipients Recipient[]
attachments Attachment[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Recipient {
id String @id @default(cuid())
messageId String
email String
message Message @relation(fields: [messageId], references: [id], onDelete: Cascade)
}
model Attachment {
id String @id @default(cuid())
messageId String
fileUrl String
fileName String
message Message @relation(fields: [messageId], references: [id], onDelete: Cascade)
}
model VerificationToken {