fix(whatsapp.gblib): .gbapp message subprocessing.
This commit is contained in:
parent
e72b030e95
commit
c14a766047
1 changed files with 28 additions and 25 deletions
|
@ -227,14 +227,15 @@ export class WhatsappDirectLine extends GBService {
|
|||
const express = require('express');
|
||||
GBServer.globals.server.use(`/audios`, express.static('work'));
|
||||
|
||||
|
||||
if (options) {
|
||||
try {
|
||||
const res = await request.post(options);
|
||||
await request.post(options);
|
||||
} catch (error) {
|
||||
GBLog.error(`Error initializing 3rd party Whatsapp provider(1) ${error.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async resetConversationId(botId, number, group = '') {
|
||||
WhatsappDirectLine.conversationIds[botId + number + group] = undefined;
|
||||
|
@ -698,6 +699,7 @@ export class WhatsappDirectLine extends GBService {
|
|||
|
||||
break;
|
||||
}
|
||||
if (options) {
|
||||
try {
|
||||
// tslint:disable-next-line: await-promise
|
||||
const result = await request.post(options);
|
||||
|
@ -706,6 +708,7 @@ export class WhatsappDirectLine extends GBService {
|
|||
GBLog.error(`Error sending file to Whatsapp provider ${error.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async sendAudioToDevice(to, url, chatId) {
|
||||
|
||||
|
@ -742,15 +745,15 @@ export class WhatsappDirectLine extends GBService {
|
|||
break;
|
||||
}
|
||||
|
||||
if (options) {
|
||||
try {
|
||||
|
||||
// tslint:disable-next-line: await-promise
|
||||
const result = await request.post(options);
|
||||
GBLog.info(`Audio ${url} sent to ${to}: ${result}`);
|
||||
} catch (error) {
|
||||
GBLog.error(`Error sending audio message to Whatsapp provider ${error.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async sendTextAsAudioToDevice(to, msg, chatId) {
|
||||
|
||||
|
@ -817,19 +820,19 @@ export class WhatsappDirectLine extends GBService {
|
|||
break;
|
||||
}
|
||||
|
||||
if (options) {
|
||||
try {
|
||||
GBLog.info(`Message [${msg}] is being sent to ${to}...`);
|
||||
// tslint:disable-next-line: await-promise
|
||||
if (this.provider !== "GeneralBots") {
|
||||
await request.post(options);
|
||||
}
|
||||
} catch (error) {
|
||||
catch (error) {
|
||||
GBLog.error(`Error sending message to Whatsapp provider ${error.message}`);
|
||||
|
||||
// TODO: Handle Error: socket hang up and retry.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async sendToDeviceEx(to, text, locale, conversationId) {
|
||||
text = await this.min.conversationalService.translate(
|
||||
|
|
Loading…
Add table
Reference in a new issue