mirror of
https://github.com/yusufipk/dead-man-switch-2.0.git
synced 2026-09-12 01:36:06 +00:00
feat: phase 4 completed
This commit is contained in:
@@ -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 }))
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user