From d9b9cd138aa2a09ad41cb02616316b1f1fb88e1a Mon Sep 17 00:00:00 2001 From: Kristen Borges Date: Wed, 3 Jul 2019 20:01:35 -0700 Subject: [PATCH] Make env variables mandatory for script to work RELEASE_NOTIFICATION_ROOM and FLOWDOCK_ORGANIZATION_NAME This will force better parity in env var setup between dev and prod enviroments --- env-var.list | 1 + scripts/suggest.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/env-var.list b/env-var.list index a557cada..36f02ae7 100644 --- a/env-var.list +++ b/env-var.list @@ -5,3 +5,4 @@ HUBOT_FLOWDOCK_API_TOKEN=$HUBOT_FLOWDOCK_API_TOKEN ZOOM_API_KEY=$ZOOM_API_KEY ZOOM_API_SECRET=$ZOOM_API_SECRET FLOWDOCK_ORGANIZATION_NAME=$FLOWDOCK_ORGANIZATION_NAME +RELEASE_NOTIFICATION_ROOM=$RELEASE_NOTIFICATION_ROOM diff --git a/scripts/suggest.js b/scripts/suggest.js index 4ca52a61..6e276b4f 100644 --- a/scripts/suggest.js +++ b/scripts/suggest.js @@ -37,6 +37,21 @@ module.exports = function(robot) { : process.env["RELEASE_NOTIFICATION_ROOM"] robot.respond(/suggest ?((?:.|\s)*)$/i, res => { + let fallbackErrorMessage = `Please ask your friendly human robot-tender to look into it.` + + if ( + !process.env["RELEASE_NOTIFICATION_ROOM"] || + !process.env["FLOWDOCK_ORGANIZATION_NAME"] + ) { + robot.logger.error( + `Missing essential configuration for the suggest command. Check your environment variables for RELEASE_NOTIFICATION_ROOM and FLOWDOCK_ORGANIZATION_NAME.`, + ) + res.send( + `Sorry, something isn't set up correctly for this command to work. ${fallbackErrorMessage}`, + ) + return + } + try { let user = res.message.user let userSuggestion = res.match[1]