Skip to content

Commit

Permalink
fix(core.gbapp): Switch of bots working by activationCode.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigorodriguez committed Jun 4, 2020
1 parent b68adc3 commit 7b84ee1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions packages/core.gbapp/services/GBMinService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,11 @@ export class GBMinService {
}
let activeMin;
if (process.env.WHATSAPP_WELCOME_DISABLED !== "true") {
// TODO: Active in two modes.
const toSwitchMin = GBServer.globals.minInstances.filter(p => p.instance.botId === text)[0];
let toSwitchMin = GBServer.globals.minInstances.filter(p => p.instance.botId.toLowerCase() === text.toLowerCase())[0];
if (!toSwitchMin){
toSwitchMin = GBServer.globals.minInstances.filter(p => p.instance.activationCode.toLowerCase() === text.toLowerCase())[0];
}

activeMin = toSwitchMin ? toSwitchMin : GBServer.globals.minBoot;

let sec = new SecService();
Expand All @@ -159,8 +162,8 @@ export class GBMinService {
} else {
// User wants to switch bots.
if (toSwitchMin !== undefined) {
const botId = text;
const instance = await this.core.loadInstanceByBotId(botId);

const instance = await this.core.loadInstanceByBotId(activeMin.botId);
await sec.updateUserInstance(id, instance.instanceId);

await (activeMin as any).whatsAppDirectLine.resetConversationId(id);
Expand Down

0 comments on commit 7b84ee1

Please sign in to comment.