summaryrefslogtreecommitdiff
path: root/app/models/project_services
diff options
context:
space:
mode:
authorSteven Sloan <stevenosloan@gmail.com>2014-10-23 14:47:28 -0400
committerSteven Sloan <stevenosloan@gmail.com>2014-10-23 14:47:28 -0400
commit7b339e61e8e4a93798807f3c90bf7179a0ecd28b (patch)
tree5ef7aecca3959eb8c097fea5815bf65bc26179e7 /app/models/project_services
parentc6efa56ee7039882625942ce29ea9fdeeffaa6cd (diff)
downloadgitlab-ce-7b339e61e8e4a93798807f3c90bf7179a0ecd28b.tar.gz
update slack-notifier to 1.0.0, use raw webhook_url per slack recommendation
per changes with slack, they’re now using “static” web hook urls that describe the team & service with IDs that don’t change if the team or service name change. their recommendation is to use the raw webhook_url instead of building it out of components to allow more flexibility this should also prevent issues cropping up with mistakes in how the urls are parsed
Diffstat (limited to 'app/models/project_services')
-rw-r--r--app/models/project_services/slack_service.rb14
1 files changed, 5 insertions, 9 deletions
diff --git a/app/models/project_services/slack_service.rb b/app/models/project_services/slack_service.rb
index 837002ef3c8..963f5440b6f 100644
--- a/app/models/project_services/slack_service.rb
+++ b/app/models/project_services/slack_service.rb
@@ -30,24 +30,20 @@ class SlackService < Service
def fields
[
- { type: 'text', name: 'webhook', placeholder: '' }
+ { type: 'text', name: 'webhook', placeholder: 'https://hooks.slack.com/services/...' }
]
end
def execute(push_data)
+ return unless webhook.present?
+
message = SlackMessage.new(push_data.merge(
project_url: project_url,
project_name: project_name
))
- credentials = webhook.match(/([\w-]*).slack.com.*services\/(.*)/)
-
- if credentials.present?
- subdomain = credentials[1]
- token = credentials[2].split("token=").last
- notifier = Slack::Notifier.new(subdomain, token)
- notifier.ping(message.pretext, attachments: message.attachments)
- end
+ notifier = Slack::Notifier.new(webhook)
+ notifier.ping(message.pretext, attachments: message.attachments)
end
private