new(whatsapp.gblib): New provider.
This commit is contained in:
parent
c39618c182
commit
736490dd94
2 changed files with 11 additions and 7 deletions
|
@ -332,7 +332,7 @@ export class GBMinService {
|
|||
return;
|
||||
}
|
||||
|
||||
let chatapi = false;
|
||||
let chatapi = GBConfigService.get('CHATAPI');
|
||||
|
||||
if (!chatapi) {
|
||||
if (req.body.type !== 'message') {
|
||||
|
@ -386,13 +386,15 @@ export class GBMinService {
|
|||
const group = message.chatName;
|
||||
|
||||
const botGroup = await this.core.loadInstanceByBotId(group);
|
||||
if (user.instanceId !== botGroup.instanceId) {
|
||||
if (botGroup && user.instanceId !== botGroup.instanceId) {
|
||||
await sec.updateUserInstance(id, botGroup.instanceId);
|
||||
}
|
||||
activeMin = GBServer.globals.minInstances.filter
|
||||
(p => p.instance.instanceId === botGroup.instanceId)[0];
|
||||
await (activeMin as any).whatsAppDirectLine.received(req, res);
|
||||
return; // EXIT HERE.
|
||||
if (botGroup) {
|
||||
activeMin = GBServer.globals.minInstances.filter
|
||||
(p => p.instance.instanceId === botGroup.instanceId)[0];
|
||||
await (activeMin as any).whatsAppDirectLine.received(req, res);
|
||||
return; // EXIT HERE.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -506,6 +508,7 @@ export class GBMinService {
|
|||
await minInstance.whatsAppDirectLine.received(req, res);
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
GBLog.error(`Error on Whatsapp callback: ${error.data ? error.data : error}`);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ import { GBConversationalService } from '../../core.gbapp/services/GBConversatio
|
|||
import { SecService } from '../../security.gbapp/services/SecService';
|
||||
import { Messages } from '../strings';
|
||||
import { GuaribasUser } from '../../security.gbapp/models';
|
||||
import { GBConfigService } from '../../core.gbapp/services/GBConfigService';
|
||||
|
||||
/**
|
||||
* Support for Whatsapp.
|
||||
|
@ -85,7 +86,7 @@ export class WhatsappDirectLine extends GBService {
|
|||
this.whatsappServiceKey = whatsappServiceKey;
|
||||
this.whatsappServiceNumber = whatsappServiceNumber;
|
||||
this.whatsappServiceUrl = whatsappServiceUrl;
|
||||
|
||||
this.chatapi = GBConfigService.get('CHATAPI');
|
||||
}
|
||||
|
||||
public static async asyncForEach(array, callback) {
|
||||
|
|
Loading…
Add table
Reference in a new issue