feat(webhook): reenviar eventos de whatsapp en tiempo real a tiendas multistore (dripzone, sneaky, zapply, almeira-store)
This commit is contained in:
parent
349e72839d
commit
8c31428fb5
@ -47,6 +47,24 @@ function htmlToWhatsAppText(html: string): string {
|
|||||||
export async function POST(req: Request) {
|
export async function POST(req: Request) {
|
||||||
try {
|
try {
|
||||||
const payload = await req.json();
|
const payload = await req.json();
|
||||||
|
|
||||||
|
// Reenviar asíncronamente a los webhooks de las tiendas de calzado (DripZone, Sneaky, etc.)
|
||||||
|
const MULTISTORE_WEBHOOKS = [
|
||||||
|
'https://dripzone.almeira.com.co/api/webhook/whatsapp',
|
||||||
|
'https://sneaky.almeira.com.co/api/webhook/whatsapp',
|
||||||
|
'https://zapply.almeira.com.co/api/webhook/whatsapp',
|
||||||
|
'https://store.almeira.com.co/api/webhook/whatsapp',
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const targetUrl of MULTISTORE_WEBHOOKS) {
|
||||||
|
fetch(targetUrl, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify(payload),
|
||||||
|
signal: AbortSignal.timeout(3500),
|
||||||
|
}).catch(() => {});
|
||||||
|
}
|
||||||
|
|
||||||
const rawEvent = payload.event || '';
|
const rawEvent = payload.event || '';
|
||||||
const eventType = rawEvent.toLowerCase().replace(/_/g, '.');
|
const eventType = rawEvent.toLowerCase().replace(/_/g, '.');
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user