summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-12-23 19:15:47 +0000
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-12-23 19:15:47 +0000
commitf791867494a9e6fa989c331e3ea28da2d8596d27 (patch)
treeb2cf2ef7fbc8c37ef02658fcbb295e4027f40c64
parent09af88336df8e659c2d941105d009b342bcc5851 (diff)
parentd54d5465967f9473c31a2e9572a4262b671ec6a7 (diff)
downloadgitlab-ce-f791867494a9e6fa989c331e3ea28da2d8596d27.tar.gz
Merge branch 'issue_25887' into 'master'
Do not override incoming webhook channel for mattermost and slack Closes #25887 See merge request !8270
-rw-r--r--app/models/project_services/chat_notification_service.rb14
-rw-r--r--app/models/project_services/mattermost_service.rb2
-rw-r--r--app/models/project_services/slack_service.rb2
-rw-r--r--changelogs/unreleased/issue_25887.yml4
-rw-r--r--spec/support/slack_mattermost_notifications_shared_examples.rb2
5 files changed, 15 insertions, 9 deletions
diff --git a/app/models/project_services/chat_notification_service.rb b/app/models/project_services/chat_notification_service.rb
index b0556987721..b7ef44c3054 100644
--- a/app/models/project_services/chat_notification_service.rb
+++ b/app/models/project_services/chat_notification_service.rb
@@ -49,11 +49,13 @@ class ChatNotificationService < Service
return false unless message
- opt = {}
+ channel_name = get_channel_field(object_kind).presence || channel
- opt[:channel] = get_channel_field(object_kind).presence || channel || default_channel
- opt[:username] = username if username
- notifier = Slack::Notifier.new(webhook, opt)
+ opts = {}
+ opts[:channel] = channel_name if channel_name
+ opts[:username] = username if username
+
+ notifier = Slack::Notifier.new(webhook, opts)
notifier.ping(message.pretext, attachments: message.attachments, fallback: message.fallback)
true
@@ -71,7 +73,7 @@ class ChatNotificationService < Service
fields.reject { |field| field[:name].end_with?('channel') }
end
- def default_channel
+ def default_channel_placeholder
raise NotImplementedError
end
@@ -103,7 +105,7 @@ class ChatNotificationService < Service
def build_event_channels
supported_events.reduce([]) do |channels, event|
- channels << { type: 'text', name: event_channel_name(event), placeholder: default_channel }
+ channels << { type: 'text', name: event_channel_name(event), placeholder: default_channel_placeholder }
end
end
diff --git a/app/models/project_services/mattermost_service.rb b/app/models/project_services/mattermost_service.rb
index 0650f930402..ee8a0b55275 100644
--- a/app/models/project_services/mattermost_service.rb
+++ b/app/models/project_services/mattermost_service.rb
@@ -35,7 +35,7 @@ class MattermostService < ChatNotificationService
]
end
- def default_channel
+ def default_channel_placeholder
"#town-square"
end
end
diff --git a/app/models/project_services/slack_service.rb b/app/models/project_services/slack_service.rb
index 0583470d3b5..76d233a3cca 100644
--- a/app/models/project_services/slack_service.rb
+++ b/app/models/project_services/slack_service.rb
@@ -34,7 +34,7 @@ class SlackService < ChatNotificationService
]
end
- def default_channel
+ def default_channel_placeholder
"#general"
end
end
diff --git a/changelogs/unreleased/issue_25887.yml b/changelogs/unreleased/issue_25887.yml
new file mode 100644
index 00000000000..27299bbc5f9
--- /dev/null
+++ b/changelogs/unreleased/issue_25887.yml
@@ -0,0 +1,4 @@
+---
+title: Do not override incoming webhook for mattermost and slack
+merge_request:
+author:
diff --git a/spec/support/slack_mattermost_notifications_shared_examples.rb b/spec/support/slack_mattermost_notifications_shared_examples.rb
index 8582aea5fe5..74d9b8c6313 100644
--- a/spec/support/slack_mattermost_notifications_shared_examples.rb
+++ b/spec/support/slack_mattermost_notifications_shared_examples.rb
@@ -105,7 +105,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do
allow(chat_service).to receive(:username).and_return(username)
expect(Slack::Notifier).to receive(:new).
- with(webhook_url, username: username, channel: chat_service.default_channel).
+ with(webhook_url, username: username).
and_return(
double(:slack_service).as_null_object
)