From 6e401eecdef2ae450f9713965fe5dc382c01446c Mon Sep 17 00:00:00 2001 From: Allyson de Paula Date: Wed, 9 Aug 2023 16:56:38 -0300 Subject: [PATCH 1/2] Bugfix Internal Error 500: fetchInstances (apikey not found) --- src/whatsapp/controllers/instance.controller.ts | 3 ++- src/whatsapp/services/monitor.service.ts | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/whatsapp/controllers/instance.controller.ts b/src/whatsapp/controllers/instance.controller.ts index 2b62af23..900df29a 100644 --- a/src/whatsapp/controllers/instance.controller.ts +++ b/src/whatsapp/controllers/instance.controller.ts @@ -286,12 +286,13 @@ export class InstanceController { } public async fetchInstances({ instanceName }: InstanceDto) { - this.logger.verbose('requested fetchInstances from ' + instanceName + ' instance'); if (instanceName) { + this.logger.verbose('requested fetchInstances from ' + instanceName + ' instance'); this.logger.verbose('instanceName: ' + instanceName); return this.waMonitor.instanceInfo(instanceName); } + this.logger.verbose('requested fetchInstances (all instances)'); return this.waMonitor.instanceInfo(); } diff --git a/src/whatsapp/services/monitor.service.ts b/src/whatsapp/services/monitor.service.ts index 50f671d9..9df6a0e3 100644 --- a/src/whatsapp/services/monitor.service.ts +++ b/src/whatsapp/services/monitor.service.ts @@ -115,7 +115,7 @@ export class WAMonitoringService { if (this.configService.get('AUTHENTICATION').EXPOSE_IN_FETCH_INSTANCES) { instanceData.instance['serverUrl'] = this.configService.get('SERVER').URL; - instanceData.instance['apikey'] = (await this.repository.auth.find(key)).apikey; + instanceData.instance['apikey'] = (await this.repository.auth.find(key))?.apikey; instanceData.instance['chatwoot'] = chatwoot; } @@ -134,7 +134,7 @@ export class WAMonitoringService { if (this.configService.get('AUTHENTICATION').EXPOSE_IN_FETCH_INSTANCES) { instanceData.instance['serverUrl'] = this.configService.get('SERVER').URL; - instanceData.instance['apikey'] = (await this.repository.auth.find(key)).apikey; + instanceData.instance['apikey'] = (await this.repository.auth.find(key))?.apikey; instanceData.instance['chatwoot'] = chatwoot; } From 907a0ee1354247bbaa8eff3a4b682dabd0bc6b24 Mon Sep 17 00:00:00 2001 From: Allyson de Paula Date: Sat, 12 Aug 2023 15:05:10 -0300 Subject: [PATCH 2/2] Proxy test --- package.json | 1 + src/whatsapp/services/whatsapp.service.ts | 2 ++ 2 files changed, 3 insertions(+) diff --git a/package.json b/package.json index 54511a9c..384db0fd 100644 --- a/package.json +++ b/package.json @@ -73,6 +73,7 @@ "qrcode-terminal": "^0.12.0", "redis": "^4.6.5", "sharp": "^0.30.7", + "socks-proxy-agent": "^8.0.1", "uuid": "^9.0.0" }, "devDependencies": { diff --git a/src/whatsapp/services/whatsapp.service.ts b/src/whatsapp/services/whatsapp.service.ts index 6de7d847..8d439d45 100644 --- a/src/whatsapp/services/whatsapp.service.ts +++ b/src/whatsapp/services/whatsapp.service.ts @@ -121,6 +121,7 @@ import { RepositoryBroker } from '../repository/repository.manager'; import { Events, MessageSubtype, TypeMediaMessage, wa } from '../types/wa.types'; import { waMonitor } from '../whatsapp.module'; import { ChatwootService } from './chatwoot.service'; +import { SocksProxyAgent } from 'socks-proxy-agent'; export class WAStartupService { constructor( @@ -874,6 +875,7 @@ export class WAStartupService { return message; }, + // agent: new SocksProxyAgent('socks5://192.168.1.4:1080'), }; this.endSession = false;