Actualizar server.js
This commit is contained in:
@@ -1683,6 +1683,7 @@ app.put('/providers/scraped/:id', authMiddleware, async (req, res) => {
|
||||
}
|
||||
|
||||
if (stName.includes('asignado') && finalAssignedTo) {
|
||||
triggerHomeServeRobot(req.user.accountId, id, 'assign').catch(console.error);
|
||||
const waEnviadoExito = await triggerWhatsAppEvent(req.user.accountId, id, 'wa_evt_assigned');
|
||||
if (waEnviadoExito) {
|
||||
const estadoEsperando = await pool.query("SELECT id FROM service_statuses WHERE owner_id=$1 AND name='Esperando al Cliente' LIMIT 1", [req.user.accountId]);
|
||||
@@ -1878,6 +1879,7 @@ app.put("/services/set-appointment/:id", authMiddleware, async (req, res) => {
|
||||
await pool.query('UPDATE scraped_services SET raw_data = $1, assigned_to = null WHERE id = $2 AND owner_id = $3', [JSON.stringify(updatedRawData), id, req.user.accountId]);
|
||||
}
|
||||
else if (stName.includes('citado') && newDate !== "" && date !== undefined) {
|
||||
triggerHomeServeRobot(req.user.accountId, id, 'date').catch(console.error);
|
||||
const oldDate = rawActual.scheduled_date || "";
|
||||
if (oldDate === "") await triggerWhatsAppEvent(req.user.accountId, id, 'wa_evt_date');
|
||||
else if (oldDate !== newDate) await triggerWhatsAppEvent(req.user.accountId, id, 'wa_evt_update');
|
||||
@@ -1991,6 +1993,7 @@ app.post("/services/not-found/:id", authMiddleware, async (req, res) => {
|
||||
|
||||
// --- INICIO TRAZABILIDAD ---
|
||||
await registrarMovimiento(id, req.user.sub, "Intento de Contacto", `El operario reporta que el cliente no contesta. Total intentos: ${currentCalls}`);
|
||||
triggerHomeServeRobot(req.user.accountId, id, 'notfound').catch(console.error);
|
||||
// --- FIN TRAZABILIDAD ---
|
||||
|
||||
res.json({ ok: true, called_times: currentCalls });
|
||||
|
||||
Reference in New Issue
Block a user