From de4559a3813dc7b3445b12521b459aea30ae7361 Mon Sep 17 00:00:00 2001 From: Ouadie Lahdioui Date: Fri, 16 Nov 2018 23:40:36 +0100 Subject: [PATCH 01/13] Add issue_template file --- .github/issue_template.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/issue_template.md diff --git a/.github/issue_template.md b/.github/issue_template.md new file mode 100644 index 000000000..8e627caab --- /dev/null +++ b/.github/issue_template.md @@ -0,0 +1,34 @@ + +** DO NOT ERASE THESE INSTRUCTIONS WITHOUT READING THEM FIRST ** + +Please read this entire template before posting any issue to get faster response. + +Open an issue on this repository with your topic or question, providing as much detail as possible. The more we know, the better we can help. + +Before posting, search the repository to see if there's already an issue opened to avoid duplicates. + +### Are you sure this is an issue with the Botkit core module? + +For all other questions, requests or help, please feel free to join the discussion slack : https://dev4slack.slack.com + +### What are you trying to achieve or the steps to reproduce? + +Describe your issue here, include as much detail as neccessary to reproduce the issue or implement a missing functionality. + +```` +// Wrap code in markdown source tags +```` + +### What was the result you received? + +### What did you expect? + +### Screenshots and animated GIFs + +### Context: + +- Botkit version: +- Node version: +- Platform: +- Os: +- Any other relevant information: From d8dec791c0bbce8c3bf224f7ea835af8aaa7546c Mon Sep 17 00:00:00 2001 From: Julien Bras Date: Wed, 12 Dec 2018 13:41:49 -0500 Subject: [PATCH 02/13] hangouts chat: allow to use GOOGLE_APPLICATION_CREDENTIALS_DATA with json instead of a file --- lib/GoogleHangoutsBot.js | 50 ++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/lib/GoogleHangoutsBot.js b/lib/GoogleHangoutsBot.js index d970f9a81..b1e87f941 100644 --- a/lib/GoogleHangoutsBot.js +++ b/lib/GoogleHangoutsBot.js @@ -159,23 +159,43 @@ function GoogleHangoutsBot(configuration) { }); google_hangouts_botkit.middleware.spawn.use(function(worker, next) { + if(process.env.GOOGLE_APPLICATION_CREDENTIALS) { + /* + * if the env variable containing a json file path is present then do classic + * auth + */ + let params = { + scopes: 'https://www.googleapis.com/auth/chat.bot' + }; - let params = { - scopes: 'https://www.googleapis.com/auth/chat.bot' - }; - - google - .auth - .getClient(params) - .then(client => { - worker.authClient = client; - worker.api = google.chat({version: api_version, auth: worker.authClient}); - next(); - }) - .catch(err => { - console.error('Could not get google auth client !'); - throw new Error(err); + google + .auth + .getClient(params) + .then(client => { + worker.authClient = client; + worker.api = google.chat({version: api_version, auth: worker.authClient}); + next(); + }) + .catch(err => { + console.error('Could not get google auth client !'); + throw new Error(err); + }); + } + else if(process.env.GOOGLE_APPLICATION_CREDENTIALS_DATA) { + // else we use the env containing the actual data + let keys = JSON.parse(process.env.GOOGLE_APPLICATION_CREDENTIALS_DATA); + let client = google.auth.fromJSON(keys); + client.scopes = ['https://www.googleapis.com/auth/chat.bot']; + worker.authClient = client; + worker.api = google.chat({ + version: api_version, + auth: worker.authClient }); + next(); + } + else { + throw new Error('Can\'t find GOOGLE_APPLICATION_CREDENTIALS or GOOGLE_APPLICATION_CREDENTIALS_DATA, auth failed'); + } }); google_hangouts_botkit.middleware.normalize.use(function handlePostback(bot, message, next) { From 567a7fbe993fca99439a5ba64bff1043f56de35e Mon Sep 17 00:00:00 2001 From: Joseph Petersen Date: Tue, 18 Dec 2018 09:08:31 +0100 Subject: [PATCH 03/13] set useQuerystring to true PHP-style array argument is never valid in Slack API --- lib/Slack_web_api.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Slack_web_api.js b/lib/Slack_web_api.js index 1bada7b77..5c6be8400 100755 --- a/lib/Slack_web_api.js +++ b/lib/Slack_web_api.js @@ -251,6 +251,7 @@ module.exports = function(bot, config) { bot.debug('** API CALL: ' + url); var params = { url: url, + useQuerystring: true, headers: { 'User-Agent': bot.userAgent(), } From a08d8f58aeb4b55b1ac679ec5e27755d4d28d4ef Mon Sep 17 00:00:00 2001 From: Julien Bras Date: Tue, 18 Dec 2018 13:36:21 -0500 Subject: [PATCH 04/13] hangouts chat: allow to use GOOGLE_APPLICATION_CREDENTIALS_DATA with json instead of a file // optimise --- lib/GoogleHangoutsBot.js | 72 +++++++++++++++------------------------- 1 file changed, 26 insertions(+), 46 deletions(-) diff --git a/lib/GoogleHangoutsBot.js b/lib/GoogleHangoutsBot.js index b1e87f941..abbea051f 100644 --- a/lib/GoogleHangoutsBot.js +++ b/lib/GoogleHangoutsBot.js @@ -159,54 +159,34 @@ function GoogleHangoutsBot(configuration) { }); google_hangouts_botkit.middleware.spawn.use(function(worker, next) { - if(process.env.GOOGLE_APPLICATION_CREDENTIALS) { - /* - * if the env variable containing a json file path is present then do classic - * auth - */ - let params = { - scopes: 'https://www.googleapis.com/auth/chat.bot' - }; + let params = { + scopes: 'https://www.googleapis.com/auth/chat.bot', + ...configuration.google_auth_params + }; - google - .auth - .getClient(params) - .then(client => { - worker.authClient = client; - worker.api = google.chat({version: api_version, auth: worker.authClient}); - next(); - }) - .catch(err => { - console.error('Could not get google auth client !'); - throw new Error(err); - }); - } - else if(process.env.GOOGLE_APPLICATION_CREDENTIALS_DATA) { - // else we use the env containing the actual data - let keys = JSON.parse(process.env.GOOGLE_APPLICATION_CREDENTIALS_DATA); - let client = google.auth.fromJSON(keys); - client.scopes = ['https://www.googleapis.com/auth/chat.bot']; - worker.authClient = client; - worker.api = google.chat({ - version: api_version, - auth: worker.authClient + google + .auth + .getClient(params) + .then(client => { + worker.authClient = client; + worker.api = google.chat({version: api_version, auth: worker.authClient}); + next(); + }) + .catch(err => { + console.error('Could not get google auth client !'); + throw new Error(err); }); - next(); - } - else { - throw new Error('Can\'t find GOOGLE_APPLICATION_CREDENTIALS or GOOGLE_APPLICATION_CREDENTIALS_DATA, auth failed'); - } - }); - - google_hangouts_botkit.middleware.normalize.use(function handlePostback(bot, message, next) { - message.user = message.user.name; - if (message.message) { - message.channel = message.message.thread.name; - message.text = message.message.argumentText ? message.message.argumentText.trim() : ''; - } else { - message.channel = message.space.name; - } - next(); + }); + + google_hangouts_botkit.middleware.normalize.use(function handlePostback(bot, message, next) { + message.user = message.user.name; + if (message.message) { + message.channel = message.message.thread.name; + message.text = message.message.argumentText ? message.message.argumentText.trim() : ''; + } else { + message.channel = message.space.name; + } + next(); }); google_hangouts_botkit.middleware.categorize.use(function(bot, message, next) { From c28c734df354477908567854af40422f837d21b9 Mon Sep 17 00:00:00 2001 From: Julien Bras Date: Tue, 18 Dec 2018 13:40:36 -0500 Subject: [PATCH 05/13] hangouts chat: clean up PR --- lib/GoogleHangoutsBot.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/GoogleHangoutsBot.js b/lib/GoogleHangoutsBot.js index abbea051f..2b25d4e9d 100644 --- a/lib/GoogleHangoutsBot.js +++ b/lib/GoogleHangoutsBot.js @@ -159,9 +159,10 @@ function GoogleHangoutsBot(configuration) { }); google_hangouts_botkit.middleware.spawn.use(function(worker, next) { + let params = { scopes: 'https://www.googleapis.com/auth/chat.bot', - ...configuration.google_auth_params + ...configuration.google_auth_params }; google @@ -176,17 +177,17 @@ function GoogleHangoutsBot(configuration) { console.error('Could not get google auth client !'); throw new Error(err); }); - }); - - google_hangouts_botkit.middleware.normalize.use(function handlePostback(bot, message, next) { - message.user = message.user.name; - if (message.message) { - message.channel = message.message.thread.name; - message.text = message.message.argumentText ? message.message.argumentText.trim() : ''; - } else { - message.channel = message.space.name; - } - next(); + }); + + google_hangouts_botkit.middleware.normalize.use(function handlePostback(bot, message, next) { + message.user = message.user.name; + if (message.message) { + message.channel = message.message.thread.name; + message.text = message.message.argumentText ? message.message.argumentText.trim() : ''; + } else { + message.channel = message.space.name; + } + next(); }); google_hangouts_botkit.middleware.categorize.use(function(bot, message, next) { From 76849ac8e9935eef9cc247fa7bdf5963350a375f Mon Sep 17 00:00:00 2001 From: Komran Rashidov Date: Tue, 18 Dec 2018 16:16:56 -0700 Subject: [PATCH 06/13] Change 500 to 404 when team not found --- lib/SlackBot.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/SlackBot.js b/lib/SlackBot.js index 24f9ef5c3..33be8b449 100755 --- a/lib/SlackBot.js +++ b/lib/SlackBot.js @@ -285,7 +285,7 @@ function Slackbot(configuration) { if (!slack_botkit.config.clientId) { bot = slack_botkit.spawn({}); } else { - return res.status(500).send(); + return res.status(404).send(); } } else { // spawn a bot @@ -303,7 +303,7 @@ function Slackbot(configuration) { if (!team.bot) { slack_botkit.log.error('No bot identity found.'); - return res.status(500).send(); + return res.status(404).send(); } } From 18061f7b7c17b235e14a8aafce5864202d0fbde7 Mon Sep 17 00:00:00 2001 From: Ben Brown Date: Thu, 20 Dec 2018 13:22:13 -0600 Subject: [PATCH 07/13] Update changelog.md --- changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index a635b2aad..062b228fd 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,6 @@ # Change Log -[View the official Botkit roadmap](https://github.com/howdyai/botkit/projects/7) for upcoming changes and features. +[View the official Botkit roadmap](https://github.com/howdyai/botkit/projects/9) for upcoming changes and features. [Want to contribute? Read our guide!](https://github.com/howdyai/botkit/blob/master/CONTRIBUTING.md) From 31909c5b2e4db0238194b1f5f68812ab6e9564a2 Mon Sep 17 00:00:00 2001 From: Ben Brown Date: Thu, 20 Dec 2018 15:01:24 -0600 Subject: [PATCH 08/13] update changelog --- changelog.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/changelog.md b/changelog.md index 062b228fd..79daf3552 100644 --- a/changelog.md +++ b/changelog.md @@ -4,6 +4,13 @@ [Want to contribute? Read our guide!](https://github.com/howdyai/botkit/blob/master/CONTRIBUTING.md) + +# Next Release (in master on Github) + +* [set useQuerystring to true in Slack API](https://github.com/howdyai/botkit/pull/1547) +* [hangouts chat: allow to consume auth data from env var instead of file](https://github.com/howdyai/botkit/pull/1543) + + # 0.7.0 This release is the first major step towards [deprecating Botkit Studio](https://github.com/howdyai/botkit/issues/1534), From 350b66a209d73667f0ad48e7a3c09f0b8eb005df Mon Sep 17 00:00:00 2001 From: Ben Brown Date: Thu, 20 Dec 2018 15:04:13 -0600 Subject: [PATCH 09/13] update eslint config to allow object spread operator --- .eslintrc.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.eslintrc.json b/.eslintrc.json index 5319f5a6a..333784de9 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -26,5 +26,9 @@ }, "env": { "es6": true -} +}, + "parserOptions": { + "ecmaVersion": 9, + "sourceType": "module" + } } From 69fe2753c9d53a1b701b0066cd0b70ca955f4902 Mon Sep 17 00:00:00 2001 From: Ben Brown Date: Thu, 20 Dec 2018 15:06:56 -0600 Subject: [PATCH 10/13] Update issue_template.md --- .github/issue_template.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/issue_template.md b/.github/issue_template.md index 8e627caab..06297088b 100644 --- a/.github/issue_template.md +++ b/.github/issue_template.md @@ -9,11 +9,11 @@ Before posting, search the repository to see if there's already an issue opened ### Are you sure this is an issue with the Botkit core module? -For all other questions, requests or help, please feel free to join the discussion slack : https://dev4slack.slack.com +For all other questions, requests or help, please feel free to join the discussion slack : https://community.botkit.ai ### What are you trying to achieve or the steps to reproduce? -Describe your issue here, include as much detail as neccessary to reproduce the issue or implement a missing functionality. +Describe your issue here, include as much detail as necessary to reproduce the issue or implement a missing functionality. ```` // Wrap code in markdown source tags @@ -28,7 +28,7 @@ Describe your issue here, include as much detail as neccessary to reproduce the ### Context: - Botkit version: +- Messaging Platform: - Node version: -- Platform: - Os: - Any other relevant information: From c940b00309170317dc5cf99bf19e7a555c8498fc Mon Sep 17 00:00:00 2001 From: Ben Brown Date: Thu, 20 Dec 2018 15:08:53 -0600 Subject: [PATCH 11/13] update changelog --- changelog.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index 79daf3552..30098f1e0 100644 --- a/changelog.md +++ b/changelog.md @@ -7,9 +7,9 @@ # Next Release (in master on Github) -* [set useQuerystring to true in Slack API](https://github.com/howdyai/botkit/pull/1547) -* [hangouts chat: allow to consume auth data from env var instead of file](https://github.com/howdyai/botkit/pull/1543) - +* Slack: [set useQuerystring to true in Slack API](https://github.com/howdyai/botkit/pull/1547) +* Slack: [Change 500 webserver status to 404 when team not found](https://github.com/howdyai/botkit/pull/1548) +* Google Hangouts: [allow to consume auth data from env var instead of file](https://github.com/howdyai/botkit/pull/1543) # 0.7.0 From c56aa493dc99039ce3f6bf800c1b7e23b801b9fe Mon Sep 17 00:00:00 2001 From: Ben Brown Date: Thu, 20 Dec 2018 16:31:13 -0600 Subject: [PATCH 12/13] Create .travis.yml --- .travis.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..587bd3e03 --- /dev/null +++ b/.travis.yml @@ -0,0 +1 @@ +language: node_js From 54a87242fac9104cf8e6f521aeeb11738bc780b2 Mon Sep 17 00:00:00 2001 From: Ben Brown Date: Thu, 20 Dec 2018 16:39:38 -0600 Subject: [PATCH 13/13] Update .travis.yml --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 587bd3e03..b1a72c73c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1 +1,3 @@ language: node_js +node_js: +- lts/*