From 78079e945565452e8905ea2848436aea3e6847be Mon Sep 17 00:00:00 2001 From: Carlos Narro Date: Tue, 9 Jun 2026 18:00:14 +0200 Subject: [PATCH] =?UTF-8?q?Bot:=20carpeta=20de=20sesi=C3=B3n=20Baileys=20c?= =?UTF-8?q?onfigurable=20+=20/debug=20captura=20todos=20los=20eventos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BAILEYS_AUTH_DIR permite arrancar una sesión limpia (QR fresco) sin perder la persistencia (subcarpeta del volumen) — para re-vincular cuando WhatsApp deja muerto el dispositivo tras varios reinicios. Y messages.upsert ahora registra en /debug todos los eventos (incluido type != notify) antes de filtrar. Co-Authored-By: Claude Opus 4.8 --- mvp/Whatsapp-bot/src/whatsapp/whatsapp.service.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mvp/Whatsapp-bot/src/whatsapp/whatsapp.service.ts b/mvp/Whatsapp-bot/src/whatsapp/whatsapp.service.ts index 7aa0077..a0f093c 100644 --- a/mvp/Whatsapp-bot/src/whatsapp/whatsapp.service.ts +++ b/mvp/Whatsapp-bot/src/whatsapp/whatsapp.service.ts @@ -41,7 +41,7 @@ interface LeadContext { export class WhatsappService implements OnModuleInit, OnModuleDestroy { private readonly logger = new Logger(WhatsappService.name); private sock: WASocket | null = null; - private authDir = path.join(process.cwd(), 'auth_info_baileys'); + private authDir = process.env.BAILEYS_AUTH_DIR || path.join(process.cwd(), 'auth_info_baileys'); private readonly ultimoMsgPorJid = new Map(); private baileysLogger = pino({ level: 'info' }); @@ -223,14 +223,17 @@ export class WhatsappService implements OnModuleInit, OnModuleDestroy { }); this.sock.ev.on('messages.upsert', async ({ messages, type }) => { - if (type !== 'notify') return; for (const msg of messages) { this.webhookListener.pushInbound({ + type, remoteJid: msg.key.remoteJid ?? null, fromMe: !!msg.key.fromMe, msgType: msg.message ? Object.keys(msg.message)[0] : null, at: new Date().toISOString(), }); + } + if (type !== 'notify') return; + for (const msg of messages) { if (msg.key.fromMe) continue; if (!msg.key.remoteJid) continue; if (msg.key.remoteJid.includes('@g.us')) continue;