From 1a0acaa575a2c242deacd690e2d899347c65f1fc Mon Sep 17 00:00:00 2001 From: Rodrigo Rodriguez Date: Sat, 9 Sep 2023 12:37:53 -0300 Subject: [PATCH] fix(all): Fix user switching on a single chip. --- .../whatsapp.gblib/services/WhatsappDirectLine.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/whatsapp.gblib/services/WhatsappDirectLine.ts b/packages/whatsapp.gblib/services/WhatsappDirectLine.ts index c8ccb59c..b389c490 100644 --- a/packages/whatsapp.gblib/services/WhatsappDirectLine.ts +++ b/packages/whatsapp.gblib/services/WhatsappDirectLine.ts @@ -1043,11 +1043,6 @@ export class WhatsappDirectLine extends GBService { let urlMin: any = GBServer.globals.minInstances.filter(p => p.instance.botId === botId)[0]; - const botNumber = urlMin ? urlMin.core.getParam(urlMin.instance, 'Bot Number', null) : null; - if (botNumber) { - GBLog.info(`${user.userSystemId} user changed Bot to: ${botId}.`); - user = await sec.updateUserInstance(user.userSystemId, urlMin.instance.instanceId); - } let activeMin; // Processes group behaviour. @@ -1102,10 +1097,15 @@ export class WhatsappDirectLine extends GBService { p.instance.activationCode ? p.instance.activationCode.toLowerCase() === text.toLowerCase() : false )[0]; } - + const botNumber = urlMin ? urlMin.core.getParam(urlMin.instance, 'Bot Number', null) : null; + // If bot has a fixed Find active bot instance. activeMin = botNumber ? urlMin : toSwitchMin ? toSwitchMin : GBServer.globals.minBoot; + if (botNumber) { + GBLog.info(`${user.userSystemId} user changed Bot to: ${botId}.`); + user = await sec.updateUserInstance(user.userSystemId, urlMin.instance.instanceId); + } // If it is the first time for the user, tries to auto-execute // start dialog if any is specified in Config.xlsx.