Skip to content

Commit

Permalink
fix(core.gbapp): Healthly status fixed for WhatsApp.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigorodriguez committed May 12, 2020
1 parent bb95f3d commit 7fbb4cc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 7 additions & 1 deletion packages/core.gbapp/services/GBMinService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions packages/whatsapp.gblib/services/WhatsappDirectLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}` ,
Expand All @@ -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";

}

Expand Down

0 comments on commit 7fbb4cc

Please sign in to comment.