Initial commit: page-manager Next.js app with Coolify deploy support
Replace Vercel-specific infra (Cron, Blob) with self-hosted equivalents for deployment to Coolify: in-container cron scheduler (scripts/cron-runner.mjs) and disk-based upload storage served via /api/uploads/[...path]. Add Dockerfile, .dockerignore, and /api/health for container health checks. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { requirePageAction } from "@/lib/auth/user";
|
||||
import { getPageCredentials } from "@/lib/facebook/tokens";
|
||||
import { listConversations, type InboxPlatform } from "@/lib/facebook/inbox";
|
||||
import { errorResponse } from "@/lib/http";
|
||||
|
||||
/** `?platform=messenger|instagram&after=` — read live from Graph. */
|
||||
export async function GET(req: Request, ctx: RouteContext<"/api/inbox/[pageId]/conversations">) {
|
||||
const { pageId } = await ctx.params;
|
||||
const auth = await requirePageAction(pageId, "view");
|
||||
if (!auth.ok) return auth.response;
|
||||
|
||||
const q = new URL(req.url).searchParams;
|
||||
const platform: InboxPlatform = q.get("platform") === "instagram" ? "instagram" : "messenger";
|
||||
try {
|
||||
const page = await getPageCredentials(pageId);
|
||||
if (platform === "instagram" && !page.igUserId) return NextResponse.json({ conversations: [], nextCursor: null });
|
||||
const result = await listConversations(page, platform, { after: q.get("after") ?? undefined });
|
||||
return NextResponse.json(result);
|
||||
} catch (e) {
|
||||
return errorResponse(e, "inbox:list");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user