fix(core.gbapp): Healthly status fixed for WhatsApp.
This commit is contained in:
parent
bb95f3d116
commit
7fbb4ccc52
2 changed files with 10 additions and 4 deletions
|
@ -249,7 +249,13 @@ export class GBMinService {
|
||||||
server.get(`/${min.instance.botId}/check`, async (req, res) => {
|
server.get(`/${min.instance.botId}/check`, async (req, res) => {
|
||||||
try {
|
try {
|
||||||
if (min.whatsAppDirectLine != undefined && instance.whatsappServiceKey !== null) {
|
if (min.whatsAppDirectLine != undefined && instance.whatsappServiceKey !== null) {
|
||||||
min.whatsAppDirectLine.check(min);
|
if (!await min.whatsAppDirectLine.check(min)) {
|
||||||
|
const error = `WhatsApp API lost connection.`;
|
||||||
|
GBLog.error(error);
|
||||||
|
res.status(500).send(error);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
res.status(200).send(`General Bot ${min.botId} is healthly.`);
|
res.status(200).send(`General Bot ${min.botId} is healthly.`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
@ -132,7 +132,7 @@ export class WhatsappDirectLine extends GBService {
|
||||||
|
|
||||||
public async check() {
|
public async check() {
|
||||||
|
|
||||||
GBLog.info(`GBWhatsapp: Cheking server...`);
|
GBLog.info(`GBWhatsapp: Checking server...`);
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
url: urlJoin(this.whatsappServiceUrl, 'status') + `?token=${this.min.instance.whatsappServiceKey}` ,
|
url: urlJoin(this.whatsappServiceUrl, 'status') + `?token=${this.min.instance.whatsappServiceKey}` ,
|
||||||
|
@ -141,8 +141,8 @@ export class WhatsappDirectLine extends GBService {
|
||||||
};
|
};
|
||||||
|
|
||||||
const res = await request(options);
|
const res = await request(options);
|
||||||
|
const json = JSON.parse(res);
|
||||||
return res.body.accountStatus === "authenticated";
|
return json.accountStatus === "authenticated";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue