Skip to content

Commit 2de0b61

Browse files
committed
fix: adjusts in proxy
1 parent d75163a commit 2de0b61

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

src/whatsapp/controllers/instance.controller.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { RepositoryBroker } from '../repository/repository.manager';
1111
import { AuthService, OldToken } from '../services/auth.service';
1212
import { ChatwootService } from '../services/chatwoot.service';
1313
import { WAMonitoringService } from '../services/monitor.service';
14+
import { ProxyService } from '../services/proxy.service';
1415
import { RabbitmqService } from '../services/rabbitmq.service';
1516
import { SettingsService } from '../services/settings.service';
1617
import { SqsService } from '../services/sqs.service';
@@ -32,6 +33,7 @@ export class InstanceController {
3233
private readonly settingsService: SettingsService,
3334
private readonly websocketService: WebsocketService,
3435
private readonly rabbitmqService: RabbitmqService,
36+
private readonly proxyService: ProxyService,
3537
private readonly sqsService: SqsService,
3638
private readonly typebotService: TypebotService,
3739
private readonly cache: RedisCache,
@@ -73,6 +75,7 @@ export class InstanceController {
7375
typebot_delay_message,
7476
typebot_unknown_message,
7577
typebot_listening_from_me,
78+
proxy,
7679
}: InstanceDto) {
7780
try {
7881
this.logger.verbose('requested createInstance from ' + instanceName + ' instance');
@@ -247,6 +250,18 @@ export class InstanceController {
247250
}
248251
}
249252

253+
if (proxy) {
254+
this.logger.verbose('creating proxy');
255+
try {
256+
this.proxyService.create(instance, {
257+
enabled: true,
258+
proxy,
259+
});
260+
} catch (error) {
261+
this.logger.log(error);
262+
}
263+
}
264+
250265
let sqsEvents: string[];
251266

252267
if (sqs_enabled) {
@@ -377,6 +392,7 @@ export class InstanceController {
377392
},
378393
settings,
379394
qrcode: getQrcode,
395+
proxy,
380396
};
381397

382398
this.logger.verbose('instance created');
@@ -486,6 +502,7 @@ export class InstanceController {
486502
name_inbox: instance.instanceName,
487503
webhook_url: `${urlServer}/chatwoot/webhook/${encodeURIComponent(instance.instanceName)}`,
488504
},
505+
proxy,
489506
};
490507
} catch (error) {
491508
this.logger.error(error.message[0]);

src/whatsapp/dto/instance.dto.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,5 @@ export class InstanceDto {
3232
typebot_delay_message?: number;
3333
typebot_unknown_message?: string;
3434
typebot_listening_from_me?: boolean;
35-
proxy_enabled?: boolean;
36-
proxy_proxy?: string;
35+
proxy?: string;
3736
}

src/whatsapp/services/whatsapp.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1297,7 +1297,7 @@ export class WAStartupService {
12971297
let options;
12981298

12991299
if (this.localProxy.enabled) {
1300-
this.logger.verbose('Proxy enabled');
1300+
this.logger.info('Proxy enabled: ' + this.localProxy.proxy);
13011301

13021302
if (this.localProxy.proxy.includes('proxyscrape')) {
13031303
const response = await axios.get(this.localProxy.proxy);

0 commit comments

Comments
 (0)