diff --git a/src/whatsapp/controllers/instance.controller.ts b/src/whatsapp/controllers/instance.controller.ts index 5409a7dd..66b94396 100644 --- a/src/whatsapp/controllers/instance.controller.ts +++ b/src/whatsapp/controllers/instance.controller.ts @@ -11,6 +11,7 @@ import { RepositoryBroker } from '../repository/repository.manager'; import { AuthService, OldToken } from '../services/auth.service'; import { ChatwootService } from '../services/chatwoot.service'; import { WAMonitoringService } from '../services/monitor.service'; +import { ProxyService } from '../services/proxy.service'; import { RabbitmqService } from '../services/rabbitmq.service'; import { SettingsService } from '../services/settings.service'; import { SqsService } from '../services/sqs.service'; @@ -32,6 +33,7 @@ export class InstanceController { private readonly settingsService: SettingsService, private readonly websocketService: WebsocketService, private readonly rabbitmqService: RabbitmqService, + private readonly proxyService: ProxyService, private readonly sqsService: SqsService, private readonly typebotService: TypebotService, private readonly cache: RedisCache, @@ -73,6 +75,7 @@ export class InstanceController { typebot_delay_message, typebot_unknown_message, typebot_listening_from_me, + proxy, }: InstanceDto) { try { this.logger.verbose('requested createInstance from ' + instanceName + ' instance'); @@ -247,6 +250,18 @@ export class InstanceController { } } + if (proxy) { + this.logger.verbose('creating proxy'); + try { + this.proxyService.create(instance, { + enabled: true, + proxy, + }); + } catch (error) { + this.logger.log(error); + } + } + let sqsEvents: string[]; if (sqs_enabled) { @@ -377,6 +392,7 @@ export class InstanceController { }, settings, qrcode: getQrcode, + proxy, }; this.logger.verbose('instance created'); @@ -486,6 +502,7 @@ export class InstanceController { name_inbox: instance.instanceName, webhook_url: `${urlServer}/chatwoot/webhook/${encodeURIComponent(instance.instanceName)}`, }, + proxy, }; } catch (error) { this.logger.error(error.message[0]); diff --git a/src/whatsapp/dto/instance.dto.ts b/src/whatsapp/dto/instance.dto.ts index 84e2b1de..c63620c5 100644 --- a/src/whatsapp/dto/instance.dto.ts +++ b/src/whatsapp/dto/instance.dto.ts @@ -32,6 +32,5 @@ export class InstanceDto { typebot_delay_message?: number; typebot_unknown_message?: string; typebot_listening_from_me?: boolean; - proxy_enabled?: boolean; - proxy_proxy?: string; + proxy?: string; } diff --git a/src/whatsapp/services/whatsapp.service.ts b/src/whatsapp/services/whatsapp.service.ts index ac755ad4..d1a7fb5b 100644 --- a/src/whatsapp/services/whatsapp.service.ts +++ b/src/whatsapp/services/whatsapp.service.ts @@ -1297,7 +1297,7 @@ export class WAStartupService { let options; if (this.localProxy.enabled) { - this.logger.verbose('Proxy enabled'); + this.logger.info('Proxy enabled: ' + this.localProxy.proxy); if (this.localProxy.proxy.includes('proxyscrape')) { const response = await axios.get(this.localProxy.proxy);