feat: phase 4 completed

This commit is contained in:
Yusuf İpek
2025-12-27 14:28:33 +03:00
parent 70d246bc17
commit 226935e67d
12 changed files with 510 additions and 31 deletions
@@ -0,0 +1,29 @@
import { NextResponse } from "next/server";
import { getServerSession } from "next-auth";
import { authOptions } from "@/lib/auth/options";
import { prisma } from "@/lib/prisma";
export async function GET(
req: Request,
{ params }: { params: Promise<{ messageId: string }> }
) {
const { messageId } = await params;
const session = await getServerSession(authOptions);
if (!session?.user?.id) {
return new NextResponse("Unauthorized", { status: 401 });
}
const message = await prisma.message.findUnique({
where: { id: messageId, userId: session.user.id },
include: { attachments: true },
});
if (!message) {
return new NextResponse("Not found", { status: 404 });
}
return NextResponse.json(
message.attachments.map((a) => ({ id: a.id, fileName: a.fileName }))
);
}
+2 -1
View File
@@ -16,7 +16,7 @@ export async function PATCH(
try {
const body = await req.json();
const { title, content, recipients, checkInterval } = body;
const { title, content, recipients, checkInterval, isEncrypted } = body;
const existingMessage = await prisma.message.findUnique({
where: { id: messageId, userId: session.user.id },
@@ -40,6 +40,7 @@ export async function PATCH(
title,
content,
checkInterval,
isEncrypted: isEncrypted || existingMessage.isEncrypted,
recipients: {
create: recipients.map((email: string) => ({ email })),
},
+2 -1
View File
@@ -12,7 +12,7 @@ export async function POST(req: Request) {
try {
const body = await req.json();
const { title, content, recipients, checkInterval } = body;
const { title, content, recipients, checkInterval, isEncrypted } = body;
const message = await prisma.message.create({
data: {
@@ -20,6 +20,7 @@ export async function POST(req: Request) {
title,
content,
checkInterval,
isEncrypted: isEncrypted || false,
recipients: {
create: recipients.map((email: string) => ({ email })),
},