Skip to content

Commit e8764dd

Browse files
committed
fix: Fix the problem when disconnecting the instance and connecting again using mongodb
1 parent a869d38 commit e8764dd

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* Include instance Id field in the instance configuration
1313
* Fixed the pairing code
1414
* Adjusts in typebot
15+
* Fix the problem when disconnecting the instance and connecting again using mongodb
1516

1617

1718
# 1.6.0 (2023-12-12 17:24)

src/whatsapp/services/monitor.service.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -277,12 +277,6 @@ export class WAMonitoringService {
277277

278278
public async cleaningUp(instanceName: string) {
279279
this.logger.verbose('cleaning up instance: ' + instanceName);
280-
if (this.redis.ENABLED) {
281-
this.logger.verbose('cleaning up instance in redis: ' + instanceName);
282-
this.cache.reference = instanceName;
283-
await this.cache.delAll();
284-
return;
285-
}
286280

287281
if (this.db.ENABLED && this.db.SAVE_DATA.INSTANCE) {
288282
this.logger.verbose('cleaning up instance in database: ' + instanceName);
@@ -294,6 +288,13 @@ export class WAMonitoringService {
294288
return;
295289
}
296290

291+
if (this.redis.ENABLED) {
292+
this.logger.verbose('cleaning up instance in redis: ' + instanceName);
293+
this.cache.reference = instanceName;
294+
await this.cache.delAll();
295+
return;
296+
}
297+
297298
this.logger.verbose('cleaning up instance in files: ' + instanceName);
298299
rmSync(join(INSTANCE_DIR, instanceName), { recursive: true, force: true });
299300
}
@@ -441,8 +442,8 @@ export class WAMonitoringService {
441442
this.eventEmitter.on('logout.instance', async (instanceName: string) => {
442443
this.logger.verbose('logout instance: ' + instanceName);
443444
try {
444-
// this.logger.verbose('request cleaning up instance: ' + instanceName);
445-
// this.cleaningUp(instanceName);
445+
this.logger.verbose('request cleaning up instance: ' + instanceName);
446+
this.cleaningUp(instanceName);
446447
} finally {
447448
this.logger.warn(`Instance "${instanceName}" - LOGOUT`);
448449
}

src/whatsapp/services/whatsapp.service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,7 +1387,7 @@ export class WAStartupService {
13871387
},
13881388
logger: P({ level: this.logBaileys }),
13891389
printQRInTerminal: false,
1390-
browser: ['Chrome (Linux)', session.NAME, release()],
1390+
browser: number ? ['Chrome (Linux)', session.NAME, release()] : browser,
13911391
version,
13921392
markOnlineOnConnect: this.localSettings.always_online,
13931393
retryRequestDelayMs: 10,
@@ -1454,7 +1454,7 @@ export class WAStartupService {
14541454

14551455
const { version } = await fetchLatestBaileysVersion();
14561456
const session = this.configService.get<ConfigSessionPhone>('CONFIG_SESSION_PHONE');
1457-
// const browser: WABrowserDescription = [session.CLIENT, session.NAME, release()];
1457+
const browser: WABrowserDescription = [session.CLIENT, session.NAME, release()];
14581458

14591459
let options;
14601460

@@ -1474,7 +1474,7 @@ export class WAStartupService {
14741474
},
14751475
logger: P({ level: this.logBaileys }),
14761476
printQRInTerminal: false,
1477-
browser: ['Chrome (Linux)', session.NAME, release()],
1477+
browser: this.phoneNumber ? ['Chrome (Linux)', session.NAME, release()] : browser,
14781478
version,
14791479
markOnlineOnConnect: this.localSettings.always_online,
14801480
retryRequestDelayMs: 10,

0 commit comments

Comments
 (0)