fix: adjusts in proxy

This commit is contained in:
Davidson Gomes 2023-12-01 20:09:19 -03:00
parent d75163aa57
commit 2de0b61726
3 changed files with 19 additions and 3 deletions

View File

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

View File

@ -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;
}

View File

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