Skip to content
This repository has been archived by the owner on Mar 25, 2022. It is now read-only.

Commit

Permalink
Allow disabling of review queries
Browse files Browse the repository at this point in the history
  • Loading branch information
miklosaubert committed Sep 28, 2018
1 parent 7686856 commit df0844c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions app/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
8 changes: 4 additions & 4 deletions app/slackapp/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
};
Expand Down Expand Up @@ -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;
};

0 comments on commit df0844c

Please sign in to comment.