import { type NextRequest, NextResponse } from 'next/server' import { getSession } from '@/lib/session' import { updateBookmark } from '@/lib/forum-social' export const runtime = 'nodejs' export const dynamic = 'force-dynamic' /** Guarda nota + recordatorio del marcador (crea el marcador si no existía). */ 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, note = '', remindAt: number | null = null try { const b = await req.json() postId = Number(b?.postId) || 0 note = String(b?.note || '') remindAt = b?.remindAt ? Number(b.remindAt) : null } catch { /* */ } if (!postId) return NextResponse.json({ ok: false }, { status: 400 }) const ok = await updateBookmark(accountId, postId, note, remindAt) return NextResponse.json({ ok, bookmarked: true, note, remindAt }, { status: ok ? 200 : 400 }) }