Skip to content

Commit a931ee7

Browse files
committed
fix: logout wa business instance
1 parent bc69447 commit a931ee7

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

src/whatsapp/controllers/instance.controller.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -664,11 +664,7 @@ export class InstanceController {
664664
}
665665

666666
try {
667-
this.logger.verbose('logging out instance: ' + instanceName);
668-
await this.waMonitor.waInstances[instanceName]?.client?.logout('Log out instance: ' + instanceName);
669-
670-
this.logger.verbose('close connection instance: ' + instanceName);
671-
this.waMonitor.waInstances[instanceName]?.client?.ws?.close();
667+
this.waMonitor.waInstances[instanceName]?.logoutInstance();
672668

673669
return { status: 'SUCCESS', error: false, response: { message: 'Instance logged out' } };
674670
} catch (error) {

src/whatsapp/services/whatsapp.baileys.service.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,14 @@ export class BaileysStartupService extends WAStartupService {
147147
return this.stateConnection;
148148
}
149149

150+
public async logoutInstance() {
151+
this.logger.verbose('logging out instance: ' + this.instanceName);
152+
await this.client?.logout('Log out instance: ' + this.instanceName);
153+
154+
this.logger.verbose('close connection instance: ' + this.instanceName);
155+
this.client?.ws?.close();
156+
}
157+
150158
public async getProfileName() {
151159
this.logger.verbose('Getting profile name');
152160

src/whatsapp/services/whatsapp.business.service.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ export class BusinessStartupService extends WAStartupService {
6464
};
6565
}
6666

67+
public async logoutInstance() {
68+
this.logger.verbose('Logging out instance');
69+
await this.closeClient();
70+
}
71+
6772
private async post(message: any, params: string) {
6873
try {
6974
const integration = await this.findIntegration();

0 commit comments

Comments
 (0)