mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-13 15:14:49 -06:00
refactor: integration folders and fix manager bugs
This commit is contained in:
parent
beafc62403
commit
6a62ae85fc
File diff suppressed because one or more lines are too long
2
manager/dist/index.html
vendored
2
manager/dist/index.html
vendored
@ -5,7 +5,7 @@
|
||||
<link rel="icon" type="image/png" href="/assets/images/evolution-logo.png" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Evolution Manager</title>
|
||||
<script type="module" crossorigin src="/assets/index-C6xnilvd.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-TzDLYu1M.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-BJ9JMAl_.css">
|
||||
</head>
|
||||
<body>
|
||||
|
@ -17,7 +17,7 @@ export class ProxyController {
|
||||
throw new NotFoundException(`The "${instance.instanceName}" instance does not exist`);
|
||||
}
|
||||
|
||||
if (!data.enabled) {
|
||||
if (!data?.enabled) {
|
||||
data.host = '';
|
||||
data.port = '';
|
||||
data.protocol = '';
|
||||
|
@ -141,7 +141,7 @@ export class EvolutionStartupService extends ChannelStartupService {
|
||||
pushName: messageRaw.pushName,
|
||||
});
|
||||
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot.enabled) {
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot?.enabled) {
|
||||
const chatwootSentMessage = await this.chatwootService.eventWhatsapp(
|
||||
Events.MESSAGES_UPSERT,
|
||||
{ instanceName: this.instance.name, instanceId: this.instanceId },
|
||||
@ -182,7 +182,7 @@ export class EvolutionStartupService extends ChannelStartupService {
|
||||
|
||||
this.sendDataWebhook(Events.CONTACTS_UPDATE, contactRaw);
|
||||
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot.enabled) {
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot?.enabled) {
|
||||
await this.chatwootService.eventWhatsapp(
|
||||
Events.CONTACTS_UPDATE,
|
||||
{ instanceName: this.instance.name, instanceId: this.instanceId },
|
||||
@ -246,7 +246,7 @@ export class EvolutionStartupService extends ChannelStartupService {
|
||||
|
||||
this.sendDataWebhook(Events.SEND_MESSAGE, messageRaw);
|
||||
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot.enabled && !isIntegration) {
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot?.enabled && !isIntegration) {
|
||||
this.chatwootService.eventWhatsapp(
|
||||
Events.SEND_MESSAGE,
|
||||
{ instanceName: this.instance.name, instanceId: this.instanceId },
|
||||
@ -254,7 +254,7 @@ export class EvolutionStartupService extends ChannelStartupService {
|
||||
);
|
||||
}
|
||||
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot.enabled && isIntegration)
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot?.enabled && isIntegration)
|
||||
await chatbotController.emit({
|
||||
instance: { instanceName: this.instance.name, instanceId: this.instanceId },
|
||||
remoteJid: messageRaw.key.remoteJid,
|
||||
|
@ -482,7 +482,7 @@ export class BusinessStartupService extends ChannelStartupService {
|
||||
pushName: messageRaw.pushName,
|
||||
});
|
||||
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot.enabled) {
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot?.enabled) {
|
||||
const chatwootSentMessage = await this.chatwootService.eventWhatsapp(
|
||||
Events.MESSAGES_UPSERT,
|
||||
{ instanceName: this.instance.name, instanceId: this.instanceId },
|
||||
@ -525,7 +525,7 @@ export class BusinessStartupService extends ChannelStartupService {
|
||||
|
||||
this.sendDataWebhook(Events.CONTACTS_UPDATE, contactRaw);
|
||||
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot.enabled) {
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot?.enabled) {
|
||||
await this.chatwootService.eventWhatsapp(
|
||||
Events.CONTACTS_UPDATE,
|
||||
{ instanceName: this.instance.name, instanceId: this.instanceId },
|
||||
@ -588,7 +588,7 @@ export class BusinessStartupService extends ChannelStartupService {
|
||||
data: message,
|
||||
});
|
||||
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot.enabled) {
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot?.enabled) {
|
||||
this.chatwootService.eventWhatsapp(
|
||||
Events.MESSAGES_DELETE,
|
||||
{ instanceName: this.instance.name, instanceId: this.instanceId },
|
||||
@ -908,7 +908,7 @@ export class BusinessStartupService extends ChannelStartupService {
|
||||
|
||||
this.sendDataWebhook(Events.SEND_MESSAGE, messageRaw);
|
||||
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot.enabled && !isIntegration) {
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot?.enabled && !isIntegration) {
|
||||
this.chatwootService.eventWhatsapp(
|
||||
Events.SEND_MESSAGE,
|
||||
{ instanceName: this.instance.name, instanceId: this.instanceId },
|
||||
@ -916,7 +916,7 @@ export class BusinessStartupService extends ChannelStartupService {
|
||||
);
|
||||
}
|
||||
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot.enabled && isIntegration)
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot?.enabled && isIntegration)
|
||||
await chatbotController.emit({
|
||||
instance: { instanceName: this.instance.name, instanceId: this.instanceId },
|
||||
remoteJid: messageRaw.key.remoteJid,
|
||||
|
@ -221,7 +221,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
statusCode: DisconnectReason.badSession,
|
||||
});
|
||||
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot.enabled) {
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot?.enabled) {
|
||||
this.chatwootService.eventWhatsapp(
|
||||
Events.QRCODE_UPDATED,
|
||||
{ instanceName: this.instance.name, instanceId: this.instanceId },
|
||||
@ -279,7 +279,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
},
|
||||
});
|
||||
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot.enabled) {
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot?.enabled) {
|
||||
this.chatwootService.eventWhatsapp(
|
||||
Events.QRCODE_UPDATED,
|
||||
{ instanceName: this.instance.name, instanceId: this.instanceId },
|
||||
@ -347,7 +347,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
},
|
||||
});
|
||||
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot.enabled) {
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot?.enabled) {
|
||||
this.chatwootService.eventWhatsapp(
|
||||
Events.STATUS_INSTANCE,
|
||||
{ instanceName: this.instance.name, instanceId: this.instanceId },
|
||||
@ -392,7 +392,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
},
|
||||
});
|
||||
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot.enabled) {
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot?.enabled) {
|
||||
this.chatwootService.eventWhatsapp(
|
||||
Events.CONNECTION_UPDATE,
|
||||
{ instanceName: this.instance.name, instanceId: this.instanceId },
|
||||
@ -499,7 +499,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
|
||||
let options;
|
||||
|
||||
if (this.localProxy.enabled) {
|
||||
if (this.localProxy?.enabled) {
|
||||
this.logger.info('Proxy enabled: ' + this.localProxy?.host);
|
||||
|
||||
if (this.localProxy?.host?.includes('proxyscrape')) {
|
||||
@ -694,7 +694,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
|
||||
if (
|
||||
this.configService.get<Chatwoot>('CHATWOOT').ENABLED &&
|
||||
this.localChatwoot.enabled &&
|
||||
this.localChatwoot?.enabled &&
|
||||
this.localChatwoot.importContacts &&
|
||||
contactsRaw.length
|
||||
) {
|
||||
@ -810,7 +810,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
let timestampLimitToImport = null;
|
||||
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED) {
|
||||
const daysLimitToImport = this.localChatwoot.enabled ? this.localChatwoot.daysLimitImportMessages : 1000;
|
||||
const daysLimitToImport = this.localChatwoot?.enabled ? this.localChatwoot.daysLimitImportMessages : 1000;
|
||||
|
||||
const date = new Date();
|
||||
timestampLimitToImport = new Date(date.setDate(date.getDate() - daysLimitToImport)).getTime() / 1000;
|
||||
@ -918,7 +918,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
|
||||
if (
|
||||
this.configService.get<Chatwoot>('CHATWOOT').ENABLED &&
|
||||
this.localChatwoot.enabled &&
|
||||
this.localChatwoot?.enabled &&
|
||||
this.localChatwoot.importMessages &&
|
||||
messagesRaw.length > 0
|
||||
) {
|
||||
@ -979,7 +979,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
const editedMessage =
|
||||
received.message?.protocolMessage || received.message?.editedMessage?.message?.protocolMessage;
|
||||
if (editedMessage) {
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot.enabled)
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot?.enabled)
|
||||
this.chatwootService.eventWhatsapp(
|
||||
'messages.edit',
|
||||
{ instanceName: this.instance.name, instanceId: this.instance.id },
|
||||
@ -1055,7 +1055,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
|
||||
if (
|
||||
this.configService.get<Chatwoot>('CHATWOOT').ENABLED &&
|
||||
this.localChatwoot.enabled &&
|
||||
this.localChatwoot?.enabled &&
|
||||
!received.key.id.includes('@broadcast')
|
||||
) {
|
||||
const chatwootSentMessage = await this.chatwootService.eventWhatsapp(
|
||||
@ -1192,7 +1192,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
|
||||
this.sendDataWebhook(Events.CONTACTS_UPDATE, contactRaw);
|
||||
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot.enabled) {
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot?.enabled) {
|
||||
await this.chatwootService.eventWhatsapp(
|
||||
Events.CONTACTS_UPDATE,
|
||||
{ instanceName: this.instance.name, instanceId: this.instanceId },
|
||||
@ -1242,7 +1242,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
}
|
||||
|
||||
if (status[update.status] === 'READ' && key.fromMe) {
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot.enabled) {
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot?.enabled) {
|
||||
this.chatwootService.eventWhatsapp(
|
||||
'messages.read',
|
||||
{ instanceName: this.instance.name, instanceId: this.instanceId },
|
||||
@ -1298,7 +1298,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
data: message,
|
||||
});
|
||||
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot.enabled) {
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot?.enabled) {
|
||||
this.chatwootService.eventWhatsapp(
|
||||
Events.MESSAGES_DELETE,
|
||||
{ instanceName: this.instance.name, instanceId: this.instanceId },
|
||||
@ -1554,7 +1554,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
|
||||
if (
|
||||
this.configService.get<Chatwoot>('CHATWOOT').ENABLED &&
|
||||
this.localChatwoot.enabled &&
|
||||
this.localChatwoot?.enabled &&
|
||||
this.localChatwoot.importMessages &&
|
||||
this.isSyncNotificationFromUsedSyncType(msg)
|
||||
) {
|
||||
@ -1809,7 +1809,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
const isWA = (await this.whatsappNumber({ numbers: [number] }))?.shift();
|
||||
|
||||
if (!isWA.exists && !isJidGroup(isWA.jid) && !isWA.jid.includes('@broadcast')) {
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot.enabled) {
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot?.enabled) {
|
||||
const body = {
|
||||
key: { remoteJid: isWA.jid },
|
||||
};
|
||||
@ -1941,7 +1941,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
|
||||
this.sendDataWebhook(Events.SEND_MESSAGE, messageRaw);
|
||||
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot.enabled && !isIntegration) {
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot?.enabled && !isIntegration) {
|
||||
this.chatwootService.eventWhatsapp(
|
||||
Events.SEND_MESSAGE,
|
||||
{ instanceName: this.instance.name, instanceId: this.instanceId },
|
||||
@ -1949,7 +1949,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
);
|
||||
}
|
||||
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot.enabled && isIntegration)
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot?.enabled && isIntegration)
|
||||
await chatbotController.emit({
|
||||
instance: { instanceName: this.instance.name, instanceId: this.instanceId },
|
||||
remoteJid: messageRaw.key.remoteJid,
|
||||
@ -2226,7 +2226,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
responseType: 'arraybuffer',
|
||||
};
|
||||
|
||||
if (this.localProxy.enabled) {
|
||||
if (this.localProxy?.enabled) {
|
||||
config = {
|
||||
...config,
|
||||
httpsAgent: makeProxyAgent({
|
||||
@ -2283,7 +2283,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
responseType: 'arraybuffer',
|
||||
};
|
||||
|
||||
if (this.localProxy.enabled) {
|
||||
if (this.localProxy?.enabled) {
|
||||
config = {
|
||||
...config,
|
||||
httpsAgent: makeProxyAgent({
|
||||
@ -3016,7 +3016,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
responseType: 'arraybuffer',
|
||||
};
|
||||
|
||||
if (this.localProxy.enabled) {
|
||||
if (this.localProxy?.enabled) {
|
||||
config = {
|
||||
...config,
|
||||
httpsAgent: makeProxyAgent({
|
||||
@ -3264,7 +3264,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
responseType: 'arraybuffer',
|
||||
};
|
||||
|
||||
if (this.localProxy.enabled) {
|
||||
if (this.localProxy?.enabled) {
|
||||
config = {
|
||||
...config,
|
||||
httpsAgent: makeProxyAgent({
|
||||
|
@ -19,7 +19,7 @@ export class ChatwootController {
|
||||
public async createChatwoot(instance: InstanceDto, data: ChatwootDto) {
|
||||
if (!this.configService.get<Chatwoot>('CHATWOOT').ENABLED) throw new BadRequestException('Chatwoot is disabled');
|
||||
|
||||
if (data.enabled) {
|
||||
if (data?.enabled) {
|
||||
if (!isURL(data.url, { require_tld: false })) {
|
||||
throw new BadRequestException('url is not valid');
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ export class DifyController extends ChatbotController implements ChatbotControll
|
||||
try {
|
||||
const bot = await this.botRepository.create({
|
||||
data: {
|
||||
enabled: data.enabled,
|
||||
enabled: data?.enabled,
|
||||
description: data.description,
|
||||
botType: data.botType,
|
||||
apiUrl: data.apiUrl,
|
||||
@ -331,7 +331,7 @@ export class DifyController extends ChatbotController implements ChatbotControll
|
||||
id: botId,
|
||||
},
|
||||
data: {
|
||||
enabled: data.enabled,
|
||||
enabled: data?.enabled,
|
||||
botType: data.botType,
|
||||
apiUrl: data.apiUrl,
|
||||
apiKey: data.apiKey,
|
||||
|
@ -145,7 +145,7 @@ export class FlowiseController extends ChatbotController implements ChatbotContr
|
||||
try {
|
||||
const bot = await this.botRepository.create({
|
||||
data: {
|
||||
enabled: data.enabled,
|
||||
enabled: data?.enabled,
|
||||
description: data.description,
|
||||
apiUrl: data.apiUrl,
|
||||
apiKey: data.apiKey,
|
||||
@ -318,7 +318,7 @@ export class FlowiseController extends ChatbotController implements ChatbotContr
|
||||
id: botId,
|
||||
},
|
||||
data: {
|
||||
enabled: data.enabled,
|
||||
enabled: data?.enabled,
|
||||
apiUrl: data.apiUrl,
|
||||
apiKey: data.apiKey,
|
||||
expire: data.expire,
|
||||
|
@ -145,7 +145,7 @@ export class GenericController extends ChatbotController implements ChatbotContr
|
||||
try {
|
||||
const bot = await this.botRepository.create({
|
||||
data: {
|
||||
enabled: data.enabled,
|
||||
enabled: data?.enabled,
|
||||
description: data.description,
|
||||
apiUrl: data.apiUrl,
|
||||
apiKey: data.apiKey,
|
||||
@ -318,7 +318,7 @@ export class GenericController extends ChatbotController implements ChatbotContr
|
||||
id: botId,
|
||||
},
|
||||
data: {
|
||||
enabled: data.enabled,
|
||||
enabled: data?.enabled,
|
||||
apiUrl: data.apiUrl,
|
||||
apiKey: data.apiKey,
|
||||
expire: data.expire,
|
||||
|
@ -314,7 +314,7 @@ export class OpenaiController extends ChatbotController implements ChatbotContro
|
||||
try {
|
||||
const bot = await this.botRepository.create({
|
||||
data: {
|
||||
enabled: data.enabled,
|
||||
enabled: data?.enabled,
|
||||
description: data.description,
|
||||
openaiCredsId: data.openaiCredsId,
|
||||
botType: data.botType,
|
||||
@ -528,7 +528,7 @@ export class OpenaiController extends ChatbotController implements ChatbotContro
|
||||
id: botId,
|
||||
},
|
||||
data: {
|
||||
enabled: data.enabled,
|
||||
enabled: data?.enabled,
|
||||
openaiCredsId: data.openaiCredsId,
|
||||
botType: data.botType,
|
||||
assistantId: data.assistantId,
|
||||
|
@ -151,7 +151,7 @@ export class TypebotController extends ChatbotController implements ChatbotContr
|
||||
try {
|
||||
const bot = await this.botRepository.create({
|
||||
data: {
|
||||
enabled: data.enabled,
|
||||
enabled: data?.enabled,
|
||||
description: data.description,
|
||||
url: data.url,
|
||||
typebot: data.typebot,
|
||||
@ -334,7 +334,7 @@ export class TypebotController extends ChatbotController implements ChatbotContr
|
||||
id: botId,
|
||||
},
|
||||
data: {
|
||||
enabled: data.enabled,
|
||||
enabled: data?.enabled,
|
||||
url: data.url,
|
||||
typebot: data.typebot,
|
||||
expire: data.expire,
|
||||
|
@ -382,7 +382,7 @@ export class TypebotService {
|
||||
}
|
||||
|
||||
const data = await this.createNewSession(instance, {
|
||||
enabled: findTypebot.enabled,
|
||||
enabled: findTypebot?.enabled,
|
||||
url: url,
|
||||
typebot: typebot,
|
||||
expire: expire,
|
||||
|
@ -76,7 +76,7 @@ export class EventController {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data[this.name].enabled) {
|
||||
if (!data[this.name]?.enabled) {
|
||||
data[this.name].events = [];
|
||||
} else {
|
||||
if (0 === data[this.name].events.length) {
|
||||
@ -92,7 +92,7 @@ export class EventController {
|
||||
...data,
|
||||
},
|
||||
create: {
|
||||
enabled: data[this.name].enabled,
|
||||
enabled: data[this.name]?.enabled,
|
||||
events: data[this.name].events,
|
||||
instanceId: this.monitor.waInstances[instanceName].instanceId,
|
||||
},
|
||||
|
@ -22,7 +22,7 @@ export class WebhookController extends EventController implements EventControlle
|
||||
throw new BadRequestException('Invalid "url" property');
|
||||
}
|
||||
|
||||
if (!data.webhook.enabled) {
|
||||
if (!data.webhook?.enabled) {
|
||||
data.webhook.events = [];
|
||||
} else {
|
||||
if (0 === data.webhook.events.length) {
|
||||
@ -38,7 +38,7 @@ export class WebhookController extends EventController implements EventControlle
|
||||
...data.webhook,
|
||||
},
|
||||
create: {
|
||||
enabled: data.webhook.enabled,
|
||||
enabled: data.webhook?.enabled,
|
||||
events: data.webhook.events,
|
||||
instanceId: this.monitor.waInstances[instanceName].instanceId,
|
||||
url: data.webhook.url,
|
||||
@ -61,7 +61,7 @@ export class WebhookController extends EventController implements EventControlle
|
||||
}: EmitData): Promise<void> {
|
||||
const instance = (await this.get(instanceName)) as EventDto;
|
||||
|
||||
if (!instance || !instance.webhook.enabled) {
|
||||
if (!instance || !instance.webhook?.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ export class WebsocketController extends EventController implements EventControl
|
||||
try {
|
||||
const instance = (await this.get(instanceName)) as EventDto;
|
||||
|
||||
if (!instance?.websocket.enabled) {
|
||||
if (!instance?.websocket?.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ export class ChannelStartupService {
|
||||
this.instance.token = instance.token;
|
||||
this.instance.businessId = instance.businessId;
|
||||
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot.enabled) {
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot?.enabled) {
|
||||
this.chatwootService.eventWhatsapp(
|
||||
Events.STATUS_INSTANCE,
|
||||
{ instanceName: this.instance.name },
|
||||
@ -241,7 +241,7 @@ export class ChannelStartupService {
|
||||
instanceId: this.instanceId,
|
||||
},
|
||||
data: {
|
||||
enabled: data.enabled,
|
||||
enabled: data?.enabled,
|
||||
accountId: data.accountId,
|
||||
token: data.token,
|
||||
url: data.url,
|
||||
@ -269,7 +269,7 @@ export class ChannelStartupService {
|
||||
|
||||
await this.prismaRepository.chatwoot.create({
|
||||
data: {
|
||||
enabled: data.enabled,
|
||||
enabled: data?.enabled,
|
||||
accountId: data.accountId,
|
||||
token: data.token,
|
||||
url: data.url,
|
||||
@ -312,7 +312,7 @@ export class ChannelStartupService {
|
||||
const ignoreJidsArray = Array.isArray(data.ignoreJids) ? data.ignoreJids.map((event) => String(event)) : [];
|
||||
|
||||
return {
|
||||
enabled: data.enabled,
|
||||
enabled: data?.enabled,
|
||||
accountId: data.accountId,
|
||||
token: data.token,
|
||||
url: data.url,
|
||||
@ -332,7 +332,7 @@ export class ChannelStartupService {
|
||||
}
|
||||
|
||||
public clearCacheChatwoot() {
|
||||
if (this.localChatwoot.enabled) {
|
||||
if (this.localChatwoot?.enabled) {
|
||||
this.chatwootService.getCache()?.deleteAll(this.instanceName);
|
||||
}
|
||||
}
|
||||
@ -355,7 +355,7 @@ export class ChannelStartupService {
|
||||
public async setProxy(data: ProxyDto) {
|
||||
await this.prismaRepository.proxy.create({
|
||||
data: {
|
||||
enabled: data.enabled,
|
||||
enabled: data?.enabled,
|
||||
host: data.host,
|
||||
port: data.port,
|
||||
protocol: data.protocol,
|
||||
|
Loading…
Reference in New Issue
Block a user