feat: Implement message check-in and status management, introduce flexible interval units, and add decryption routes for messages and attachments.

This commit is contained in:
Yusuf İpek
2025-12-28 14:15:16 +03:00
parent 1c91a1fe9d
commit 89968db712
17 changed files with 460 additions and 50 deletions
@@ -0,0 +1,36 @@
import { NextResponse } from 'next/server';
import { getServerSession } from 'next-auth';
import { authOptions } from '@/lib/auth/options';
import { prisma } from '@/lib/prisma';
export async function POST(
req: Request,
{ params }: { params: Promise<{ messageId: string }> }
) {
const session = await getServerSession(authOptions);
if (!session?.user?.id) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
}
const { messageId } = await params;
const { status } = await req.json();
if (!['DRAFT', 'ACTIVE'].includes(status)) {
return NextResponse.json({ error: 'Invalid status' }, { status: 400 });
}
const message = await prisma.message.findUnique({
where: { id: messageId, userId: session.user.id },
});
if (!message) {
return NextResponse.json({ error: 'Not found' }, { status: 404 });
}
const updated = await prisma.message.update({
where: { id: messageId },
data: { status, lastPing: new Date() },
});
return NextResponse.json({ success: true, status: updated.status });
}