fix(whatsapp.gblib): .gbapp message subprocessing.

This commit is contained in:
Rodrigo Rodriguez 2022-09-02 10:32:07 -03:00
parent e72b030e95
commit c14a766047

View file

@ -227,11 +227,12 @@ export class WhatsappDirectLine extends GBService {
const express = require('express');
GBServer.globals.server.use(`/audios`, express.static('work'));
try {
const res = await request.post(options);
} catch (error) {
GBLog.error(`Error initializing 3rd party Whatsapp provider(1) ${error.message}`);
if (options) {
try {
await request.post(options);
} catch (error) {
GBLog.error(`Error initializing 3rd party Whatsapp provider(1) ${error.message}`);
}
}
}
}
@ -698,12 +699,14 @@ export class WhatsappDirectLine extends GBService {
break;
}
try {
// tslint:disable-next-line: await-promise
const result = await request.post(options);
GBLog.info(`File ${url} sent to ${to}: ${result}`);
} catch (error) {
GBLog.error(`Error sending file to Whatsapp provider ${error.message}`);
if (options) {
try {
// tslint:disable-next-line: await-promise
const result = await request.post(options);
GBLog.info(`File ${url} sent to ${to}: ${result}`);
} catch (error) {
GBLog.error(`Error sending file to Whatsapp provider ${error.message}`);
}
}
}
@ -742,13 +745,13 @@ export class WhatsappDirectLine extends GBService {
break;
}
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}`);
if (options) {
try {
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}`);
}
}
}
@ -817,16 +820,16 @@ export class WhatsappDirectLine extends GBService {
break;
}
try {
GBLog.info(`Message [${msg}] is being sent to ${to}...`);
// tslint:disable-next-line: await-promise
if (this.provider !== "GeneralBots") {
if (options) {
try {
GBLog.info(`Message [${msg}] is being sent to ${to}...`);
await request.post(options);
}
} catch (error) {
GBLog.error(`Error sending message to Whatsapp provider ${error.message}`);
catch (error) {
GBLog.error(`Error sending message to Whatsapp provider ${error.message}`);
// TODO: Handle Error: socket hang up and retry.
// TODO: Handle Error: socket hang up and retry.
}
}
}
}