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) => {
|
||||
try {
|
||||
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.`);
|
||||
} catch (error) {
|
||||
|
|
|
@ -132,7 +132,7 @@ export class WhatsappDirectLine extends GBService {
|
|||
|
||||
public async check() {
|
||||
|
||||
GBLog.info(`GBWhatsapp: Cheking server...`);
|
||||
GBLog.info(`GBWhatsapp: Checking server...`);
|
||||
|
||||
const options = {
|
||||
url: urlJoin(this.whatsappServiceUrl, 'status') + `?token=${this.min.instance.whatsappServiceKey}` ,
|
||||
|
@ -141,8 +141,8 @@ export class WhatsappDirectLine extends GBService {
|
|||
};
|
||||
|
||||
const res = await request(options);
|
||||
|
||||
return res.body.accountStatus === "authenticated";
|
||||
const json = JSON.parse(res);
|
||||
return json.accountStatus === "authenticated";
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue