diff --git a/.env.example b/.env.example index f239b91..8dc4422 100644 --- a/.env.example +++ b/.env.example @@ -43,3 +43,7 @@ DATABASE_URL="file:./prisma/dev.db" # Recommended when exposing Siftly via a public URL (e.g. Cloudflare Tunnel). # SIFTLY_USERNAME=admin # SIFTLY_PASSWORD=your-passphrase-here + +# ── Import options ────────────────────────────────────────────────── +# Automatically trigger AI categorization after a successful import. +# AUTO_CATEGORIZE_AFTER_IMPORT=true diff --git a/app/api/import/twitter/route.ts b/app/api/import/twitter/route.ts index 3154484..9ce3f73 100644 --- a/app/api/import/twitter/route.ts +++ b/app/api/import/twitter/route.ts @@ -325,5 +325,16 @@ export async function POST(request: NextRequest): Promise { ) } + // Opt-in: trigger categorization in background after a successful import. + // Enable by setting AUTO_CATEGORIZE_AFTER_IMPORT=true in the environment. + if (imported > 0 && process.env.AUTO_CATEGORIZE_AFTER_IMPORT === 'true') { + const origin = request.nextUrl.origin + void fetch(`${origin}/api/categorize`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ force: false }), + }).catch(() => { /* best-effort */ }) + } + return NextResponse.json({ imported, skipped }) }