diff --git a/src/whatsapp/controllers/instance.controller.ts b/src/whatsapp/controllers/instance.controller.ts index 19184e81..196dad42 100644 --- a/src/whatsapp/controllers/instance.controller.ts +++ b/src/whatsapp/controllers/instance.controller.ts @@ -664,11 +664,7 @@ export class InstanceController { } try { - this.logger.verbose('logging out instance: ' + instanceName); - await this.waMonitor.waInstances[instanceName]?.client?.logout('Log out instance: ' + instanceName); - - this.logger.verbose('close connection instance: ' + instanceName); - this.waMonitor.waInstances[instanceName]?.client?.ws?.close(); + this.waMonitor.waInstances[instanceName]?.logoutInstance(); return { status: 'SUCCESS', error: false, response: { message: 'Instance logged out' } }; } catch (error) { diff --git a/src/whatsapp/services/whatsapp.baileys.service.ts b/src/whatsapp/services/whatsapp.baileys.service.ts index 132bc39d..e471bef2 100644 --- a/src/whatsapp/services/whatsapp.baileys.service.ts +++ b/src/whatsapp/services/whatsapp.baileys.service.ts @@ -147,6 +147,14 @@ export class BaileysStartupService extends WAStartupService { return this.stateConnection; } + public async logoutInstance() { + this.logger.verbose('logging out instance: ' + this.instanceName); + await this.client?.logout('Log out instance: ' + this.instanceName); + + this.logger.verbose('close connection instance: ' + this.instanceName); + this.client?.ws?.close(); + } + public async getProfileName() { this.logger.verbose('Getting profile name'); diff --git a/src/whatsapp/services/whatsapp.business.service.ts b/src/whatsapp/services/whatsapp.business.service.ts index 0cfa84f0..3ed1391c 100644 --- a/src/whatsapp/services/whatsapp.business.service.ts +++ b/src/whatsapp/services/whatsapp.business.service.ts @@ -64,6 +64,11 @@ export class BusinessStartupService extends WAStartupService { }; } + public async logoutInstance() { + this.logger.verbose('Logging out instance'); + await this.closeClient(); + } + private async post(message: any, params: string) { try { const integration = await this.findIntegration();