feat: sync Clientify CRM + botón Sincronizar por pestaña
El CRM solo vivía de webhooks; ahora hay pull Clientify, cron daily-sync incluye CRM, y cada módulo de Agencia tiene sync manual. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
syncAllSuperhumanTenants,
|
||||
superhumanConfigured,
|
||||
} from '@/lib/superhuman-docs';
|
||||
import { syncAllClientifyTenants } from '@/lib/clientify-sync';
|
||||
|
||||
export const dynamic = 'force-dynamic';
|
||||
export const maxDuration = 300;
|
||||
@@ -89,7 +90,23 @@ export async function GET(req: NextRequest) {
|
||||
};
|
||||
}
|
||||
|
||||
const failed = ['organic', 'ads', 'superhuman'].some(
|
||||
// 4) Clientify CRM → leads/deals
|
||||
try {
|
||||
const crm = await syncAllClientifyTenants();
|
||||
out.crm = {
|
||||
ok: true,
|
||||
synced: crm.results.filter((r) => !r.error).length,
|
||||
withErrors: crm.results.filter((r) => r.error).length,
|
||||
results: crm.results,
|
||||
};
|
||||
} catch (e) {
|
||||
out.crm = {
|
||||
ok: false,
|
||||
error: e instanceof Error ? e.message : 'crm failed',
|
||||
};
|
||||
}
|
||||
|
||||
const failed = ['organic', 'ads', 'superhuman', 'crm'].some(
|
||||
(k) => (out[k] as { ok?: boolean } | undefined)?.ok === false
|
||||
);
|
||||
return NextResponse.json(out, { status: failed ? 207 : 200 });
|
||||
|
||||
Reference in New Issue
Block a user