From edbcb82dc31f7c00c5b5d4386d1cda64dedd4524 Mon Sep 17 00:00:00 2001 From: Gerardo Laracuente Date: Mon, 7 Oct 2019 13:04:24 -0400 Subject: [PATCH 1/6] adding a conditional to allow a default webhook --- bin/handler-slack-multichannel.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/handler-slack-multichannel.rb b/bin/handler-slack-multichannel.rb index 1ad8ebe..5a44f96 100755 --- a/bin/handler-slack-multichannel.rb +++ b/bin/handler-slack-multichannel.rb @@ -244,7 +244,12 @@ def build_description end def post_data(notice, channel) - slack_webhook_url = webhook_urls[channel] + if webhook_urls[channel].nil? + slack_webhook_url = webhook_urls['default'] + else + slack_webhook_url = webhook_urls[channel] + end + uri = URI(slack_webhook_url) http = if defined?(slack_proxy_addr).nil? From 99ba78c41abd406d31c3166cb8b622922e687cbf Mon Sep 17 00:00:00 2001 From: Gerardo Laracuente Date: Tue, 8 Oct 2019 10:01:05 -0400 Subject: [PATCH 2/6] changelog update --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a92493..17453ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins ## [Unreleased] +## [4.2.0]- 2019-10-08 +### Added +- `handler-slack-multichannel.rb`: Added a conditional that enables sending to a default webhook if the provided channels do not have their own dedicated webhook. + ## [4.1.0]- 2019-05-16 ### Added - `handler-slack`: added `webhook_retries` (default: 5), `webhook_timeout` (default: 10), and `webhook_retry_sleep` configuration properties to harden against failures due to networking, rate limits, etc. (@kali-brandwatch) From 0968a700c5bfb6fc69836dcbf3deee6d43376086 Mon Sep 17 00:00:00 2001 From: Gerardo Laracuente Date: Tue, 8 Oct 2019 10:05:12 -0400 Subject: [PATCH 3/6] updating README --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2489706..437aed6 100644 --- a/README.md +++ b/README.md @@ -49,8 +49,9 @@ { "slack": { "webhook_urls": { - "no-team-alerts": "https://hooks.slack.com/services/AAAAAAA", - "all-alerts": "https://hooks.slack.com/services/BBBBBB" + "default": "https://hooks.slack.com/services/AAAAAAA" + "no-team-alerts": "https://hooks.slack.com/services/BBBBBB", + "all-alerts": "https://hooks.slack.com/services/CCCCCC" }, "channels": { "default": [ "no-team-alerts" ], From 85b3beb8d043541feefc28d34cc5d67e41faff08 Mon Sep 17 00:00:00 2001 From: Gerardo Laracuente Date: Tue, 8 Oct 2019 11:08:32 -0400 Subject: [PATCH 4/6] implementing RuboCop suggestions --- bin/handler-slack-multichannel.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/handler-slack-multichannel.rb b/bin/handler-slack-multichannel.rb index 5a44f96..9e4ca49 100755 --- a/bin/handler-slack-multichannel.rb +++ b/bin/handler-slack-multichannel.rb @@ -244,11 +244,11 @@ def build_description end def post_data(notice, channel) - if webhook_urls[channel].nil? - slack_webhook_url = webhook_urls['default'] - else - slack_webhook_url = webhook_urls[channel] - end + slack_webhook_url = if webhook_urls[channel].nil? + webhook_urls['default'] + else + webhook_urls[channel] + end uri = URI(slack_webhook_url) From 8437235639a92684779f8bfdfbd83ad815fe9b30 Mon Sep 17 00:00:00 2001 From: Gerardo Laracuente Date: Tue, 8 Oct 2019 11:19:36 -0400 Subject: [PATCH 5/6] syntax fixes --- bin/handler-slack-multichannel.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/handler-slack-multichannel.rb b/bin/handler-slack-multichannel.rb index 9e4ca49..9a263b8 100755 --- a/bin/handler-slack-multichannel.rb +++ b/bin/handler-slack-multichannel.rb @@ -245,10 +245,10 @@ def build_description def post_data(notice, channel) slack_webhook_url = if webhook_urls[channel].nil? - webhook_urls['default'] - else - webhook_urls[channel] - end + webhook_urls['default'] + else + webhook_urls[channel] + end uri = URI(slack_webhook_url) From fcfc61d8ea048f99b95126a00219b86a68870a70 Mon Sep 17 00:00:00 2001 From: Gerardo Laracuente Date: Tue, 8 Oct 2019 11:53:03 -0400 Subject: [PATCH 6/6] syntax fixes --- bin/handler-slack-multichannel.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/handler-slack-multichannel.rb b/bin/handler-slack-multichannel.rb index 9a263b8..7c37a5c 100755 --- a/bin/handler-slack-multichannel.rb +++ b/bin/handler-slack-multichannel.rb @@ -246,9 +246,9 @@ def build_description def post_data(notice, channel) slack_webhook_url = if webhook_urls[channel].nil? webhook_urls['default'] - else - webhook_urls[channel] - end + else + webhook_urls[channel] + end uri = URI(slack_webhook_url)