diff --git a/package.json b/package.json index 4d2c17cd..1828669b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "evolution-api", - "version": "1.8.2", + "version": "1.8.4", "description": "Rest api for communication with WhatsApp", "main": "./dist/src/main.js", "scripts": { diff --git a/src/api/controllers/instance.controller.ts b/src/api/controllers/instance.controller.ts index fdc8161f..eb187193 100644 --- a/src/api/controllers/instance.controller.ts +++ b/src/api/controllers/instance.controller.ts @@ -737,16 +737,11 @@ export class InstanceController { this.logger.verbose('requested deleteInstance from ' + instanceName + ' instance'); const { instance } = await this.connectionState({ instanceName }); - if (instance.state === 'open') { - throw new BadRequestException('The "' + instanceName + '" instance needs to be disconnected'); - } try { this.waMonitor.waInstances[instanceName]?.removeRabbitmqQueues(); this.waMonitor.waInstances[instanceName]?.clearCacheChatwoot(); - if (instance.state === 'connecting') { - this.logger.verbose('logging out instance: ' + instanceName); - + if (instance.state === 'connecting' || instance.state === 'open') { await this.logout({ instanceName }); } diff --git a/src/api/services/channel.service.ts b/src/api/services/channel.service.ts index 49ea9c3a..37fb1c3c 100644 --- a/src/api/services/channel.service.ts +++ b/src/api/services/channel.service.ts @@ -766,7 +766,7 @@ export class ChannelStartupService { logData['apikey'] = instanceApikey; } - this.logger.log(logData); + // this.logger.log(logData); } break; } catch (error) { @@ -834,7 +834,7 @@ export class ChannelStartupService { logData['apikey'] = instanceApikey; } - this.logger.log(logData); + // this.logger.log(logData); } break; @@ -907,7 +907,7 @@ export class ChannelStartupService { logData['apikey'] = instanceApikey; } - this.logger.log(logData); + // this.logger.log(logData); } } }); @@ -951,7 +951,7 @@ export class ChannelStartupService { logData['apikey'] = instanceApikey; } - this.logger.log(logData); + // this.logger.log(logData); } } @@ -981,7 +981,7 @@ export class ChannelStartupService { logData['apikey'] = instanceApikey; } - this.logger.log(logData); + // this.logger.log(logData); } } } @@ -1017,7 +1017,7 @@ export class ChannelStartupService { logData['apikey'] = instanceApikey; } - this.logger.log(logData); + // this.logger.log(logData); } try { @@ -1088,7 +1088,7 @@ export class ChannelStartupService { logData['apikey'] = globalApiKey; } - this.logger.log(logData); + // this.logger.log(logData); } try { diff --git a/src/api/services/channels/whatsapp.baileys.service.ts b/src/api/services/channels/whatsapp.baileys.service.ts index 190a3c8d..8f193189 100644 --- a/src/api/services/channels/whatsapp.baileys.service.ts +++ b/src/api/services/channels/whatsapp.baileys.service.ts @@ -379,12 +379,6 @@ export class BaileysStartupService extends ChannelStartupService { state: connection, statusReason: (lastDisconnect?.error as Boom)?.output?.statusCode ?? 200, }; - - this.logger.verbose('Sending data to webhook in event CONNECTION_UPDATE'); - this.sendDataWebhook(Events.CONNECTION_UPDATE, { - instance: this.instance.name, - ...this.stateConnection, - }); } if (connection === 'close') { @@ -417,6 +411,15 @@ export class BaileysStartupService extends ChannelStartupService { this.client?.ws?.close(); this.client.end(new Error('Close connection')); this.logger.verbose('Connection closed'); + + this.logger.verbose('Sending data to webhook in event CONNECTION_UPDATE'); + this.sendDataWebhook(Events.CONNECTION_UPDATE, { + instance: this.instance.name, + wuid: this.instance.wuid, + profileName: await this.getProfileName(), + profilePictureUrl: this.instance.profilePictureUrl, + ...this.stateConnection, + }); } } @@ -446,13 +449,34 @@ export class BaileysStartupService extends ChannelStartupService { { instance: this.instance.name, status: 'open', + wuid: this.instance.wuid, + profileName: await this.getProfileName(), + profilePictureUrl: this.instance.profilePictureUrl, }, ); } + + this.logger.verbose('Sending data to webhook in event CONNECTION_UPDATE'); + this.sendDataWebhook(Events.CONNECTION_UPDATE, { + instance: this.instance.name, + wuid: this.instance.wuid, + profileName: await this.getProfileName(), + profilePictureUrl: this.instance.profilePictureUrl, + ...this.stateConnection, + }); } if (connection === 'connecting') { if (this.mobile) this.sendMobileCode(); + + this.logger.verbose('Sending data to webhook in event CONNECTION_UPDATE'); + this.sendDataWebhook(Events.CONNECTION_UPDATE, { + instance: this.instance.name, + wuid: this.instance.wuid, + profileName: await this.getProfileName(), + profilePictureUrl: this.instance.profilePictureUrl, + ...this.stateConnection, + }); } }