From df0844c88e62b6b851025559e3bc007f2827eedd Mon Sep 17 00:00:00 2001 From: Miklos Aubert Date: Fri, 28 Sep 2018 14:34:20 +0200 Subject: [PATCH] Allow disabling of review queries --- app/config.js | 1 + app/slackapp/index.js | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/config.js b/app/config.js index 9419866..53cd45c 100644 --- a/app/config.js +++ b/app/config.js @@ -14,4 +14,5 @@ module.exports = { PORT: process.env.PORT || '7142', API_HOST: process.env.API_HOST || 'https://api.trustpilot.com', ENABLE_LOCAL_TUNNEL: process.env.ENABLE_LOCAL_TUNNEL, + ENABLE_REVIEW_QUERIES: true, }; diff --git a/app/slackapp/index.js b/app/slackapp/index.js index e6aafde..ca616d0 100644 --- a/app/slackapp/index.js +++ b/app/slackapp/index.js @@ -4,8 +4,7 @@ const { composeReviewMessage } = require('./lib/review-message'); const reviewReply = require('./review-reply'); const feedSettings = require('./feed-settings'); -const setupAppHandlers = (slackapp, trustpilotApi) => { - +const setupAppHandlers = (slackapp, trustpilotApi, enableReviewQueries) => { const slashCommandType = (text) => { if (/^[1-5] stars?$/i.test(text) || /^la(te)?st$/i.test(text)) { return 'review_query'; @@ -104,8 +103,9 @@ const setupAppHandlers = (slackapp, trustpilotApi) => { slackapp.on('slash_command', async (bot, message) => { bot.replyAcknowledge(); const type = slashCommandType(message.text); + const noop = () => {}; const commandHandlers = { - ['review_query']: handleReviewQuery, + ['review_query']: enableReviewQueries ? handleReviewQuery : noop, ['feed_settings']: feedSettings.handleSettingsCommand, ['test_feeds']: testFeeds, }; @@ -187,6 +187,6 @@ module.exports = (config, trustpilotApi, storage) => { rtm_receive_messages: false, // eslint-disable-line camelcase scopes: ['bot', 'incoming-webhook', 'commands'], }); - setupAppHandlers(slackapp, trustpilotApi); + setupAppHandlers(slackapp, trustpilotApi, config.ENABLE_REVIEW_QUERIES); return slackapp; };