import { type NextRequest, NextResponse } from 'next/server' import { getSession } from '@/lib/session' import { reportPost } from '@/lib/forum-social' export const runtime = 'nodejs' export const dynamic = 'force-dynamic' export async function POST(req: NextRequest) { const session = await getSession() const accountId = session.accountId ?? 0 if (!accountId) return NextResponse.json({ ok: false }, { status: 401 }) let postId = 0, reason = '', detail = '' try { const b = await req.json() postId = Number(b?.postId) || 0 reason = String(b?.reason || '') detail = String(b?.detail || '') } catch { /* */ } if (!postId || !reason) return NextResponse.json({ ok: false }, { status: 400 }) const now = Math.floor(Date.now() / 1000) const ok = await reportPost(accountId, postId, reason, detail, now) return NextResponse.json({ ok }, { status: ok ? 200 : 400 }) }