From fb64e186b59b169401b1fa3b60a43c370ced36ba Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Fri, 13 Jan 2017 20:37:14 +0100 Subject: [PATCH] Fixed issue #587 - Group restrictions not respected in slack notification. Thanks to @jepf --- .../app/controllers/_integration/slack.coffee | 12 +++++------ ...0113000002_slack_group_config_issue_587.rb | 20 +++++++++++++++++++ 2 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 db/migrate/20170113000002_slack_group_config_issue_587.rb diff --git a/app/assets/javascripts/app/controllers/_integration/slack.coffee b/app/assets/javascripts/app/controllers/_integration/slack.coffee index 106303127..e464ebf5c 100644 --- a/app/assets/javascripts/app/controllers/_integration/slack.coffee +++ b/app/assets/javascripts/app/controllers/_integration/slack.coffee @@ -26,12 +26,12 @@ class Index extends App.ControllerIntegrationBase escalation_warning: '5. Ticket Escalation Warning' configureAttributes = [ - { name: 'types', display: 'Trigger', tag: 'checkbox', options: options, 'null': false, class: 'vertical', note: 'Where notification is sent.' }, - { name: 'group_id', display: 'Group', tag: 'select', relation: 'Group', multiple: true, 'null': false, note: 'Only for this groups.' }, - { name: 'webhook', display: 'Webhook', tag: 'input', type: 'url', limit: 200, 'null': false, placeholder: 'https://hooks.slack.com/services/...' }, - { name: 'username', display: 'Username', tag: 'input', type: 'text', limit: 100, 'null': false, placeholder: 'username' }, - { name: 'channel', display: 'Channel', tag: 'input', type: 'text', limit: 100, 'null': true, placeholder: '#channel' }, - { name: 'icon_url', display: 'Icon Url', tag: 'input', type: 'url', limit: 200, 'null': true, placeholder: 'https://example.com/logo.png' }, + { name: 'types', display: 'Trigger', tag: 'checkbox', options: options, 'null': false, class: 'vertical', note: 'Where notification is sent.' }, + { name: 'group_ids', display: 'Group', tag: 'select', relation: 'Group', multiple: true, 'null': false, note: 'Only for this groups.' }, + { name: 'webhook', display: 'Webhook', tag: 'input', type: 'url', limit: 200, 'null': false, placeholder: 'https://hooks.slack.com/services/...' }, + { name: 'username', display: 'Username', tag: 'input', type: 'text', limit: 100, 'null': false, placeholder: 'username' }, + { name: 'channel', display: 'Channel', tag: 'input', type: 'text', limit: 100, 'null': true, placeholder: '#channel' }, + { name: 'icon_url', display: 'Icon Url', tag: 'input', type: 'url', limit: 200, 'null': true, placeholder: 'https://example.com/logo.png' }, ] settings = [] diff --git a/db/migrate/20170113000002_slack_group_config_issue_587.rb b/db/migrate/20170113000002_slack_group_config_issue_587.rb new file mode 100644 index 000000000..49a30f3b8 --- /dev/null +++ b/db/migrate/20170113000002_slack_group_config_issue_587.rb @@ -0,0 +1,20 @@ +class SlackGroupConfigIssue587 < ActiveRecord::Migration + def up + + # return if it's a new setup + return if !Setting.find_by(name: 'system_init_done') + + setting = Setting.find_by(name: 'slack_config') + return if !setting + + return if !setting.state_current['value'] + return if !setting.state_current['value']['items'] + config_item = setting.state_current['value']['items'].first + return if !config_item + + return if !config_item.key?('group_id') + config_item['group_ids'] = config_item.delete('group_id') + + setting.save! + end +end