Commit 20179772 authored by Marin Jankovski's avatar Marin Jankovski

Use only webhook for slack service integration.

parent 86d5a63e
...@@ -40,7 +40,7 @@ class Projects::ServicesController < Projects::ApplicationController ...@@ -40,7 +40,7 @@ class Projects::ServicesController < Projects::ApplicationController
def service_params def service_params
params.require(:service).permit( params.require(:service).permit(
:title, :token, :type, :active, :api_key, :subdomain, :title, :token, :type, :active, :api_key, :subdomain,
:room, :recipients, :project_url, :room, :recipients, :project_url, :webhook
:user_key, :device, :priority, :sound :user_key, :device, :priority, :sound
) )
end end
......
...@@ -13,10 +13,8 @@ ...@@ -13,10 +13,8 @@
# #
class SlackService < Service class SlackService < Service
prop_accessor :room, :subdomain, :token prop_accessor :webhook
validates :room, presence: true, if: :activated? validates :webhook, presence: true, if: :activated?
validates :subdomain, presence: true, if: :activated?
validates :token, presence: true, if: :activated?
def title def title
'Slack' 'Slack'
...@@ -32,9 +30,7 @@ class SlackService < Service ...@@ -32,9 +30,7 @@ class SlackService < Service
def fields def fields
[ [
{ type: 'text', name: 'subdomain', placeholder: '' }, { type: 'text', name: 'webhook', placeholder: '' }
{ type: 'text', name: 'token', placeholder: '' },
{ type: 'text', name: 'room', placeholder: 'Ex. #general' },
] ]
end end
...@@ -44,9 +40,10 @@ class SlackService < Service ...@@ -44,9 +40,10 @@ class SlackService < Service
project_name: project_name project_name: project_name
)) ))
credentials = webhook.match(/(\w*).slack.com.*token=(\w*)/)
subdomain = credentials[1]
token = credentials[2]
notifier = Slack::Notifier.new(subdomain, token) notifier = Slack::Notifier.new(subdomain, token)
notifier.channel = room
notifier.username = 'GitLab'
notifier.ping(message.pretext, attachments: message.attachments) notifier.ping(message.pretext, attachments: message.attachments)
end end
......
...@@ -108,16 +108,12 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps ...@@ -108,16 +108,12 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
step 'I fill Slack settings' do step 'I fill Slack settings' do
check 'Active' check 'Active'
fill_in 'Subdomain', with: 'gitlab' fill_in 'Webhook', with: 'https://gitlabhq.slack.com/services/hooks?token=cdIj4r4LfXUOySDUjp0tk3OI'
fill_in 'Room', with: '#gitlab'
fill_in 'Token', with: 'verySecret'
click_button 'Save' click_button 'Save'
end end
step 'I should see Slack service settings saved' do step 'I should see Slack service settings saved' do
find_field('Subdomain').value.should == 'gitlab' find_field('Webhook').value.should == 'https://gitlabhq.slack.com/services/hooks?token=cdIj4r4LfXUOySDUjp0tk3OI'
find_field('Room').value.should == '#gitlab'
find_field('Token').value.should == 'verySecret'
end end
step 'I click Pushover service link' do step 'I click Pushover service link' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment