fix: agregar SERVER_URL para links de QR

This commit is contained in:
DillusDev001 2026-09-19 16:53:43 -04:00
parent 163d58d871
commit 9ef2d375ee

View file

@ -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`);