From 8b84a9201ad251950c674af761a12fcbfbfe075b Mon Sep 17 00:00:00 2001 From: rodrigorodriguez Date: Wed, 12 Oct 2022 03:13:46 -0300 Subject: [PATCH] new(whatsapp.gblib): Native provider works in groups now. --- packages/whatsapp.gblib/services/WhatsappDirectLine.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/whatsapp.gblib/services/WhatsappDirectLine.ts b/packages/whatsapp.gblib/services/WhatsappDirectLine.ts index f2efdbd2..89a23a53 100644 --- a/packages/whatsapp.gblib/services/WhatsappDirectLine.ts +++ b/packages/whatsapp.gblib/services/WhatsappDirectLine.ts @@ -1018,7 +1018,7 @@ export class WhatsappDirectLine extends GBService { const sec = new SecService(); - let user = await sec.ensureUser(this.min.instance.instanceId, id, senderName, '', 'whatsApp', senderName, null); + let user = await sec.getUserFromSystemId(id); GBLog.info(`A WhatsApp mobile requested instance for: ${botId}.`); let urlMin: any = GBServer.globals.minInstances.filter @@ -1057,8 +1057,9 @@ export class WhatsappDirectLine extends GBService { return Object.keys(object).find(key => object[key] === value); } const botId = getKeyByValue(WhatsappDirectLine.botGroups, group); - if (botId && user.instanceId !== this.min.instance.instanceId) { - await sec.updateUserInstance(id, this.min.instance.instanceId); + if (botId && user.instanceId !== this.min.instance.instanceId || !user) { + user = await sec.ensureUser(this.min.instance.instanceId, id, senderName, '', 'whatsApp', senderName, null); + } if (botId) { activeMin = GBServer.globals.minInstances.filter