fix(whatsapp.gblib): Fixed symbol erros and added timeout to WhatsApp initialization.
This commit is contained in:
parent
63dfc03c15
commit
895fc57097
8 changed files with 17 additions and 16 deletions
|
@ -299,7 +299,7 @@ export class AzureDeployerService implements IGBInstallationDeployer {
|
|||
if (!JSON.parse(res.bodyAsText).id) {
|
||||
throw res.bodyAsText;
|
||||
}
|
||||
GBLog.info(`Bot proxy updated at: ${endpoint}.`);
|
||||
GBLog.info(`Bot updated at: ${endpoint}.`);
|
||||
}
|
||||
|
||||
public async deleteBot(botId: string, group) {
|
||||
|
|
|
@ -64,7 +64,7 @@ export class SwitchBotDialog extends IGBDialog {
|
|||
let sec = new SecService();
|
||||
let from = step.context.activity.from.id;
|
||||
const botId = step.result;
|
||||
const instance = await min.core.loadInstanceByBotId(botId);
|
||||
const instance = await min.core.loadInstance(botId);
|
||||
await sec.updateUserInstance(from, instance.instanceId);
|
||||
await step.context.sendActivity(`Opa, vamos lá!`);
|
||||
|
||||
|
|
|
@ -233,7 +233,7 @@ export class GBCoreService implements IGBCoreService {
|
|||
/**
|
||||
* Loads just one Bot instance.
|
||||
*/
|
||||
public async loadInstanceByBotId(botId: string): Promise<IGBInstance> {
|
||||
public async loadInstance(botId: string): Promise<IGBInstance> {
|
||||
const options = { where: {} };
|
||||
options.where = { botId: botId };
|
||||
|
||||
|
|
|
@ -213,7 +213,7 @@ export class GBDeployer implements IGBDeployer {
|
|||
} else {
|
||||
|
||||
let botId = GBConfigService.get('BOT_ID');
|
||||
let bootInstance = await this.core.loadInstanceByBotId(botId);
|
||||
let bootInstance = await this.core.loadInstance(botId);
|
||||
|
||||
instance.searchHost = bootInstance.searchHost;
|
||||
instance.searchIndex = bootInstance.searchIndex;
|
||||
|
|
|
@ -61,7 +61,7 @@ export class GBImporter {
|
|||
if (botId === undefined) {
|
||||
botId = GBConfigService.get('BOT_ID');
|
||||
}
|
||||
const instance = await this.core.loadInstanceByBotId(botId);
|
||||
const instance = await this.core.loadInstance(botId);
|
||||
|
||||
if (instance != null && instance.botId === null) {
|
||||
console.log(`Null BotId after load instance with botId: ${botId}.`);
|
||||
|
|
|
@ -147,7 +147,7 @@ export class GBMinService {
|
|||
activeMin = toSwitchMin ? toSwitchMin : GBServer.globals.minBoot;
|
||||
|
||||
let sec = new SecService();
|
||||
const instance = await this.core.loadInstanceByBotId(activeMin.botId);
|
||||
const instance = await this.core.loadInstance(activeMin.botId);
|
||||
let user = await sec.getUserFromSystemId(id);
|
||||
|
||||
if (user === null) {
|
||||
|
@ -158,7 +158,7 @@ export class GBMinService {
|
|||
// User wants to switch bots.
|
||||
if (toSwitchMin !== undefined) {
|
||||
const botId = text;
|
||||
const instance = await this.core.loadInstanceByBotId(botId);
|
||||
const instance = await this.core.loadInstance(botId);
|
||||
await sec.updateUserInstance(id, instance.instanceId);
|
||||
|
||||
await (activeMin as any).whatsAppDirectLine.resetConversationId(id);
|
||||
|
@ -184,13 +184,13 @@ export class GBMinService {
|
|||
|
||||
});
|
||||
|
||||
await Promise.all(
|
||||
instances.map(async instance => {
|
||||
// Gets the authorization key for each instance from Bot Service.
|
||||
|
||||
await CollectionUtil.asyncForEach(instances, async instance => {
|
||||
try{
|
||||
await this.mountBot(instance);
|
||||
})
|
||||
);
|
||||
} catch (error) {
|
||||
GBLog.error(`Error mounting bot ${instance.botId}: ${error.message}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public async unmountBot(botId: string) {
|
||||
|
@ -298,7 +298,7 @@ export class GBMinService {
|
|||
if (botId === '[default]' || botId === undefined) {
|
||||
botId = GBConfigService.get('BOT_ID');
|
||||
}
|
||||
const instance = await this.core.loadInstanceByBotId(botId);
|
||||
const instance = await this.core.loadInstance(botId);
|
||||
if (instance !== null) {
|
||||
const webchatTokenContainer = await this.getWebchatToken(instance);
|
||||
const speechToken = instance.speechKey != null ? await this.getSTSToken(instance) : null;
|
||||
|
@ -409,7 +409,7 @@ export class GBMinService {
|
|||
min.adminService = this.adminService;
|
||||
min.deployService = this.deployer;
|
||||
min.kbService = new KBService(this.core.sequelize);
|
||||
min.instance = await this.core.loadInstanceByBotId(min.botId);
|
||||
min.instance = await this.core.loadInstance(min.botId);
|
||||
min.cbMap = {};
|
||||
min.scriptMap = {};
|
||||
min.sandBoxMap = {};
|
||||
|
|
|
@ -560,7 +560,7 @@ export class KBService implements IGBKBService {
|
|||
GBLog.info(`[GBDeployer] Opening package: ${localPath}`);
|
||||
const packageObject = JSON.parse(Fs.readFileSync(urlJoin(localPath, 'package.json'), 'utf8'));
|
||||
|
||||
const instance = await core.loadInstanceByBotId(packageObject.botId);
|
||||
const instance = await core.loadInstance(packageObject.botId);
|
||||
GBLog.info(`[GBDeployer] Importing: ${localPath}`);
|
||||
const p = await deployer.deployPackageToStorage(instance.instanceId, packageName);
|
||||
await this.importKbPackage(localPath, p, instance);
|
||||
|
|
|
@ -95,6 +95,7 @@ export class WhatsappDirectLine extends GBService {
|
|||
const options = {
|
||||
method: 'POST',
|
||||
url: urlJoin(this.whatsappServiceUrl, 'webhook'),
|
||||
timeout: 10000,
|
||||
qs: {
|
||||
token: this.whatsappServiceKey,
|
||||
webhookUrl: `${GBServer.globals.publicAddress}/webhooks/whatsapp`,
|
||||
|
|
Loading…
Add table
Reference in a new issue