From 5fa02a30cb60794c93be5969d56936f938c1fd29 Mon Sep 17 00:00:00 2001 From: Rafael Reis Date: Sun, 8 Mar 2026 14:22:06 -0700 Subject: [PATCH] feat(import): opt-in auto-categorize after import via env flag --- .env.example | 4 ++++ app/api/import/twitter/route.ts | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/.env.example b/.env.example index 61d7e03..d4609a2 100644 --- a/.env.example +++ b/.env.example @@ -29,3 +29,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 + +# Optional: automatically trigger AI categorization after a successful import. +# Set to 'true' to enable. +# AUTO_CATEGORIZE_AFTER_IMPORT=true diff --git a/app/api/import/twitter/route.ts b/app/api/import/twitter/route.ts index d8ff30b..59ff994 100644 --- a/app/api/import/twitter/route.ts +++ b/app/api/import/twitter/route.ts @@ -293,5 +293,15 @@ 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') { + void fetch('http://localhost:3000/api/categorize', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ force: false }), + }).catch(() => { /* best-effort */ }) + } + return NextResponse.json({ imported, skipped }) }