Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Fixes #1916 - check for webserver before attempting to add a route
Browse files Browse the repository at this point in the history
  • Loading branch information
benbrown committed Mar 11, 2020
1 parent f045e1b commit b658660
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions packages/botbuilder-adapter-facebook/src/facebook_adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,17 @@ export class FacebookAdapter extends BotAdapter {
*/
public async init(botkit): Promise<any> {
debug('Add GET webhook endpoint for verification at: ', botkit.getConfig('webhook_uri'));
botkit.webserver.get(botkit.getConfig('webhook_uri'), (req, res) => {
if (req.query['hub.mode'] === 'subscribe') {
if (req.query['hub.verify_token'] === this.options.verify_token) {
res.send(req.query['hub.challenge']);
} else {
res.send('OK');
if (botkit.webserver) {
botkit.webserver.get(botkit.getConfig('webhook_uri'), (req, res) => {
if (req.query['hub.mode'] === 'subscribe') {
if (req.query['hub.verify_token'] === this.options.verify_token) {
res.send(req.query['hub.challenge']);
} else {
res.send('OK');
}
}
}
});
});
}
}

/**
Expand Down

0 comments on commit b658660

Please sign in to comment.