fix(core.gbapp): Switch of bots working by activationCode.
This commit is contained in:
parent
b68adc3627
commit
7b84ee112d
2 changed files with 10 additions and 7 deletions
6
package-lock.json
generated
6
package-lock.json
generated
|
@ -3273,9 +3273,9 @@
|
|||
}
|
||||
},
|
||||
"botlib": {
|
||||
"version": "1.5.4",
|
||||
"resolved": "https://registry.npmjs.org/botlib/-/botlib-1.5.4.tgz",
|
||||
"integrity": "sha512-m3VIwB1c/ZqRvkZ/Ip3zJhFDAK1kS8hSNS+J7JOJe9N2L1ajZU0QDV5ziK5KlWy5CpBx5TEMB0gJ3+SMhX+aCQ==",
|
||||
"version": "1.5.5",
|
||||
"resolved": "https://registry.npmjs.org/botlib/-/botlib-1.5.5.tgz",
|
||||
"integrity": "sha512-fugvHvp0XDqAflOFxbLknC49ijDL0P0c8DDztLSj2sUfwoJ6J2YqVIU8kkVW1OdjNGvXCNUjiZS6ZHEuHaGdMQ==",
|
||||
"requires": {
|
||||
"async": "3.1.0",
|
||||
"botbuilder": "4.7.0",
|
||||
|
|
|
@ -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();
|
||||
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue