feat: restringe soloAdmin (Bucefalo CRM) a agentes, default WhatsApp+fallbackEmail y archivado reversible

This commit is contained in:
urieljareth
2026-11-25 08:54:28 -06:00
parent 0d4f19f35d
commit 670265a390
31 changed files with 672 additions and 78 deletions
+11 -1
View File
@@ -25,7 +25,17 @@ export async function GET(request: NextRequest) {
},
orderBy: { createdAt: "asc" },
});
return applyHeaders(NextResponse.json(paquetes), auth.rateLimitHeaders);
const salida =
auth.actor.type === "agent"
? paquetes.map((p) => ({
...p,
fases: p.fases.map((f) => ({
...f,
servicios: f.servicios.filter((sp) => !sp.servicio?.soloAdmin),
})),
}))
: paquetes;
return applyHeaders(NextResponse.json(salida), auth.rateLimitHeaders);
} catch (error: unknown) {
const msg = error instanceof Error ? error.message : "Error interno";
return NextResponse.json({ error: msg }, { status: 500 });