Actualizar server.js

This commit is contained in:
2026-02-20 22:08:12 +00:00
parent 7cedfc3fe4
commit 4dd21435f7

View File

@@ -640,14 +640,14 @@ async function triggerWhatsAppEvent(ownerId, serviceId, eventType) {
if (!settings[checkSwitch]) return; // Si el botón está apagado, salimos if (!settings[checkSwitch]) return; // Si el botón está apagado, salimos
// 2. Buscamos qué plantilla corresponde a este evento // 2. Buscamos qué plantilla corresponde a este evento
const tplTypeMap = { const tplTypeMap = {
'wa_evt_welcome': 'welcome', 'wa_evt_welcome': 'welcome',
'wa_evt_assigned': 'assigned', // NUEVO: Asignado a operario 'wa_evt_assigned': 'assigned', // <--- Añadir esta línea
'wa_evt_date': 'appointment', // Plantilla: Cita Creada 'wa_evt_date': 'appointment',
'wa_evt_update': 'update', // Plantilla: Modificación de Servicio 'wa_evt_update': 'update',
'wa_evt_onway': 'on_way', 'wa_evt_onway': 'on_way',
'wa_evt_survey': 'survey' 'wa_evt_survey': 'survey'
}; };
const tplQ = await pool.query("SELECT content FROM message_templates WHERE owner_id=$1 AND type=$2", [ownerId, tplTypeMap[eventType]]); const tplQ = await pool.query("SELECT content FROM message_templates WHERE owner_id=$1 AND type=$2", [ownerId, tplTypeMap[eventType]]);
if (tplQ.rowCount === 0 || !tplQ.rows[0].content) return; if (tplQ.rowCount === 0 || !tplQ.rows[0].content) return;
let text = tplQ.rows[0].content; let text = tplQ.rows[0].content;