Commit III

This commit is contained in:
DillusDev001 2026-09-19 14:16:49 -04:00
parent abc369bd04
commit 163d58d871
5 changed files with 9 additions and 12 deletions

2
.env
View file

@ -17,4 +17,4 @@ OPENWA_API_KEY=owa_k1_f3e283de607aabd68462cd449c980ab18c4f1c6286bdeea3f5e64fd863
# Configuración del worker
WORKER_INTERVAL=3000
PORT=3001
PORT=3002

View file

@ -120,6 +120,8 @@ let WorkerService = WorkerService_1 = class WorkerService {
await this.actualizarEstado(idMensajeWhatsApp, 'ERROR', 'No hay sesiones OpenWA disponibles');
return;
}
await this.actualizarEstado(idMensajeWhatsApp, 'ENVIANDO');
this.logger.log(`[${this.timestamp()}] 🔄 Estado cambiado a ENVIANDO`);
const chatId = `${telefonoDestino}@c.us`;
const mensajes = [mensaje1, mensaje2, mensaje3].filter((m) => Boolean(m));
if (mensajes.length > 0) {
@ -136,10 +138,6 @@ let WorkerService = WorkerService_1 = class WorkerService {
await this.enviarTexto(sessionId, chatId, textoConQR);
this.logger.log(`[${this.timestamp()}] ✉️ Mensaje 1 (QR como link) enviado INMEDIATO`);
}
if (mensajes.length > 1) {
await this.actualizarEstado(idMensajeWhatsApp, 'ENVIANDO');
this.logger.log(`[${this.timestamp()}] 🔄 Estado cambiado a ENVIANDO`);
}
}
else {
await this.enviarTexto(sessionId, chatId, texto1);

File diff suppressed because one or more lines are too long

View file

@ -147,6 +147,10 @@ export class WorkerService implements OnModuleInit, OnModuleDestroy {
return;
}
// Cambiar estado a ENVIANDO ANTES de enviar para evitar duplicados
await this.actualizarEstado(idMensajeWhatsApp, 'ENVIANDO');
this.logger.log(`[${this.timestamp()}] 🔄 Estado cambiado a ENVIANDO`);
const chatId = `${telefonoDestino}@c.us`;
const mensajes: string[] = [mensaje1, mensaje2, mensaje3].filter((m): m is string => Boolean(m));
@ -165,11 +169,6 @@ export class WorkerService implements OnModuleInit, OnModuleDestroy {
await this.enviarTexto(sessionId, chatId, textoConQR);
this.logger.log(`[${this.timestamp()}] ✉️ Mensaje 1 (QR como link) enviado INMEDIATO`);
}
// Cambiar estado a ENVIANDO después del primer mensaje (RECEPCION_PAQUETE tiene 3 mensajes)
if (mensajes.length > 1) {
await this.actualizarEstado(idMensajeWhatsApp, 'ENVIANDO');
this.logger.log(`[${this.timestamp()}] 🔄 Estado cambiado a ENVIANDO`);
}
} else {
await this.enviarTexto(sessionId, chatId, texto1);
this.logger.log(`[${this.timestamp()}] ✉️ Mensaje 1 enviado INMEDIATO`);

File diff suppressed because one or more lines are too long