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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let chatapi = false;
|
let chatapi = GBConfigService.get('CHATAPI');
|
||||||
|
|
||||||
if (!chatapi) {
|
if (!chatapi) {
|
||||||
if (req.body.type !== 'message') {
|
if (req.body.type !== 'message') {
|
||||||
|
@ -386,15 +386,17 @@ export class GBMinService {
|
||||||
const group = message.chatName;
|
const group = message.chatName;
|
||||||
|
|
||||||
const botGroup = await this.core.loadInstanceByBotId(group);
|
const botGroup = await this.core.loadInstanceByBotId(group);
|
||||||
if (user.instanceId !== botGroup.instanceId) {
|
if (botGroup && user.instanceId !== botGroup.instanceId) {
|
||||||
await sec.updateUserInstance(id, botGroup.instanceId);
|
await sec.updateUserInstance(id, botGroup.instanceId);
|
||||||
}
|
}
|
||||||
|
if (botGroup) {
|
||||||
activeMin = GBServer.globals.minInstances.filter
|
activeMin = GBServer.globals.minInstances.filter
|
||||||
(p => p.instance.instanceId === botGroup.instanceId)[0];
|
(p => p.instance.instanceId === botGroup.instanceId)[0];
|
||||||
await (activeMin as any).whatsAppDirectLine.received(req, res);
|
await (activeMin as any).whatsAppDirectLine.received(req, res);
|
||||||
return; // EXIT HERE.
|
return; // EXIT HERE.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Detects if the welcome message is enabled.
|
// Detects if the welcome message is enabled.
|
||||||
|
@ -506,6 +508,7 @@ export class GBMinService {
|
||||||
await minInstance.whatsAppDirectLine.received(req, res);
|
await minInstance.whatsAppDirectLine.received(req, res);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
||||||
GBLog.error(`Error on Whatsapp callback: ${error.data ? error.data : 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 { SecService } from '../../security.gbapp/services/SecService';
|
||||||
import { Messages } from '../strings';
|
import { Messages } from '../strings';
|
||||||
import { GuaribasUser } from '../../security.gbapp/models';
|
import { GuaribasUser } from '../../security.gbapp/models';
|
||||||
|
import { GBConfigService } from '../../core.gbapp/services/GBConfigService';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Support for Whatsapp.
|
* Support for Whatsapp.
|
||||||
|
@ -85,7 +86,7 @@ export class WhatsappDirectLine extends GBService {
|
||||||
this.whatsappServiceKey = whatsappServiceKey;
|
this.whatsappServiceKey = whatsappServiceKey;
|
||||||
this.whatsappServiceNumber = whatsappServiceNumber;
|
this.whatsappServiceNumber = whatsappServiceNumber;
|
||||||
this.whatsappServiceUrl = whatsappServiceUrl;
|
this.whatsappServiceUrl = whatsappServiceUrl;
|
||||||
|
this.chatapi = GBConfigService.get('CHATAPI');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async asyncForEach(array, callback) {
|
public static async asyncForEach(array, callback) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue