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;