From b839b6f7b5ea5895029b822eeacb9fe93f6c7b06 Mon Sep 17 00:00:00 2001 From: Marcellus Pelcher Date: Tue, 21 Nov 2017 21:41:38 -0800 Subject: [PATCH 1/2] Bypass updates when there is a health check What do you guys think about doing something like this? This will help users of the library a lot. https://developers.google.com/actions/console/actions-health-check --- src/dashbot-google.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/dashbot-google.js b/src/dashbot-google.js index 14f8e49..4186750 100644 --- a/src/dashbot-google.js +++ b/src/dashbot-google.js @@ -22,12 +22,13 @@ function DashBotGoogle(apiKey, urlRoot, debug, printErrors, config) { throw new Error('YOU MUST SUPPLY THE ASSISTANT OBJECT TO DASHBOT!'); } that.assistantHandle = assistant; + if (app.getArgument("is_health_check")) { + that.assistantHandle.originalDoResponse = assistant.doResponse_; + that.assistantHandle.doResponse_ = dashbotDoResponse; - that.assistantHandle.originalDoResponse = assistant.doResponse_; - that.assistantHandle.doResponse_ = dashbotDoResponse; - - that.requestBody = assistant.body_; - that.logIncoming(assistant.body_, incomingMetadata); + that.requestBody = assistant.body_; + that.logIncoming(assistant.body_, incomingMetadata); + } }; function dashbotDoResponse(response, responseCode){ @@ -94,4 +95,4 @@ function DashBotGoogle(apiKey, urlRoot, debug, printErrors, config) { }; } -module.exports = DashBotGoogle; \ No newline at end of file +module.exports = DashBotGoogle; From 410a3a2203bcab30187d5a4ca5f61bb879e806f0 Mon Sep 17 00:00:00 2001 From: Marcellus Pelcher Date: Tue, 21 Nov 2017 21:58:00 -0800 Subject: [PATCH 2/2] Fix if statement to not bypass when getArgument is not null --- src/dashbot-google.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dashbot-google.js b/src/dashbot-google.js index 4186750..90b0fd2 100644 --- a/src/dashbot-google.js +++ b/src/dashbot-google.js @@ -22,7 +22,7 @@ function DashBotGoogle(apiKey, urlRoot, debug, printErrors, config) { throw new Error('YOU MUST SUPPLY THE ASSISTANT OBJECT TO DASHBOT!'); } that.assistantHandle = assistant; - if (app.getArgument("is_health_check")) { + if (!that.assistantHandle.getArgument("is_health_check")) { that.assistantHandle.originalDoResponse = assistant.doResponse_; that.assistantHandle.doResponse_ = dashbotDoResponse;