diff --git a/src/worker/worker.service.ts b/src/worker/worker.service.ts index 5fac2bb..7a248d9 100644 --- a/src/worker/worker.service.ts +++ b/src/worker/worker.service.ts @@ -25,6 +25,7 @@ export class WorkerService implements OnModuleInit, OnModuleDestroy { private readonly openwaUrl: string; private readonly openwaApiKey: string; private readonly intervalMs: number; + private readonly serverUrl: string; // Cache de sesiones OpenWA private sesionesCache: { id: string; name: string; phone: string }[] = []; @@ -40,6 +41,7 @@ export class WorkerService implements OnModuleInit, OnModuleDestroy { this.openwaUrl = this.config.get('OPENWA_URL') || 'http://localhost:2785'; this.openwaApiKey = this.config.get('OPENWA_API_KEY') || ''; this.intervalMs = Number(this.config.get('WORKER_INTERVAL')) || 30000; + this.serverUrl = this.config.get('SERVER_URL') || 'http://localhost:3000'; } onModuleInit() { @@ -164,7 +166,7 @@ export class WorkerService implements OnModuleInit, OnModuleDestroy { this.logger.log(`[${this.timestamp()}] šŸ“·āœ‰ļø Mensaje 1 (QR + imagen) enviado INMEDIATO`); } catch { this.logger.warn(`[${this.timestamp()}] āš ļø Error enviando imagen, usando fallback con link`); - const fullUrl = urlQR.startsWith('http') ? urlQR : `${this.apiUrl.replace('/v1', '')}${urlQR}`; + const fullUrl = urlQR.startsWith('http') ? urlQR : `${this.serverUrl}${urlQR}`; const textoConQR = `${texto1}\n\nšŸ”— *Ver QR:* ${fullUrl}`; await this.enviarTexto(sessionId, chatId, textoConQR); this.logger.log(`[${this.timestamp()}] āœ‰ļø Mensaje 1 (QR como link) enviado INMEDIATO`);