diff --git a/src/api/controllers/instance.controller.ts b/src/api/controllers/instance.controller.ts index 90d9622a..9c4f358c 100644 --- a/src/api/controllers/instance.controller.ts +++ b/src/api/controllers/instance.controller.ts @@ -753,7 +753,7 @@ export class InstanceController { this.logger.verbose('deleting instance: ' + instanceName); try { - this.waMonitor.waInstances[instanceName].sendDataWebhook(Events.INSTANCE_DELETE, { + this.waMonitor.waInstances[instanceName]?.sendDataWebhook(Events.INSTANCE_DELETE, { instanceName, instanceId: (await this.repository.auth.find(instanceName))?.instanceId, }); diff --git a/src/api/services/channels/whatsapp.baileys.service.ts b/src/api/services/channels/whatsapp.baileys.service.ts index 911f4c66..4dafe2aa 100644 --- a/src/api/services/channels/whatsapp.baileys.service.ts +++ b/src/api/services/channels/whatsapp.baileys.service.ts @@ -1478,7 +1478,7 @@ export class BaileysStartupService extends ChannelStartupService { this.logger.verbose('Sending data to webhook in event LABELS_ASSOCIATION'); // Atualiza labels nos chats - if (database.SAVE_DATA.CHATS) { + if (database.ENABLED && database.SAVE_DATA.CHATS) { const chats = await this.repository.chat.find({ where: { owner: this.instance.name, @@ -1486,7 +1486,7 @@ export class BaileysStartupService extends ChannelStartupService { }); const chat = chats.find((c) => c.id === data.association.chatId); if (chat) { - let labels = [...chat?.labels]; + let labels = [...chat.labels]; if (data.type === 'remove') { labels = labels.filter((label) => label !== data.association.labelId); } else if (data.type === 'add') { diff --git a/src/api/services/monitor.service.ts b/src/api/services/monitor.service.ts index c197b843..c342e977 100644 --- a/src/api/services/monitor.service.ts +++ b/src/api/services/monitor.service.ts @@ -271,9 +271,8 @@ export class WAMonitoringService { this.logger.verbose('cleaning up instance in files: ' + instanceName); if (this.providerSession?.ENABLED) { await this.providerFiles.removeSession(instanceName); - } else { - rmSync(join(INSTANCE_DIR, instanceName), { recursive: true, force: true }); } + rmSync(join(INSTANCE_DIR, instanceName), { recursive: true, force: true }); } public async cleaningStoreFiles(instanceName: string) { @@ -281,9 +280,8 @@ export class WAMonitoringService { this.logger.verbose('cleaning store files instance: ' + instanceName); if (this.providerSession?.ENABLED) { await this.providerFiles.removeSession(instanceName); - } else { - rmSync(join(INSTANCE_DIR, instanceName), { recursive: true, force: true }); } + rmSync(join(INSTANCE_DIR, instanceName), { recursive: true, force: true }); execSync(`rm -rf ${join(STORE_DIR, 'chats', instanceName)}`); execSync(`rm -rf ${join(STORE_DIR, 'contacts', instanceName)}`);