2018-08-10 02:45:01 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-08-19 05:11:36 -04:00
|
|
|
class FlowdockService < Service
|
2014-09-07 20:54:18 -04:00
|
|
|
prop_accessor :token
|
2013-08-19 05:11:36 -04:00
|
|
|
validates :token, presence: true, if: :activated?
|
|
|
|
|
|
|
|
def title
|
|
|
|
'Flowdock'
|
|
|
|
end
|
|
|
|
|
|
|
|
def description
|
|
|
|
'Flowdock is a collaboration web app for technical teams.'
|
|
|
|
end
|
|
|
|
|
2016-12-27 07:44:24 -05:00
|
|
|
def self.to_param
|
2013-08-19 05:11:36 -04:00
|
|
|
'flowdock'
|
|
|
|
end
|
|
|
|
|
|
|
|
def fields
|
|
|
|
[
|
2017-05-22 06:07:12 -04:00
|
|
|
{ type: 'text', name: 'token', placeholder: 'Flowdock Git source token', required: true }
|
2013-08-19 05:11:36 -04:00
|
|
|
]
|
|
|
|
end
|
|
|
|
|
2016-12-27 07:44:24 -05:00
|
|
|
def self.supported_events
|
2015-02-28 11:33:18 -05:00
|
|
|
%w(push)
|
|
|
|
end
|
|
|
|
|
2015-02-20 08:49:26 -05:00
|
|
|
def execute(data)
|
2015-02-28 11:33:18 -05:00
|
|
|
return unless supported_events.include?(data[:object_kind])
|
2015-02-19 00:02:57 -05:00
|
|
|
|
2013-08-19 05:11:36 -04:00
|
|
|
Flowdock::Git.post(
|
2015-02-20 08:49:26 -05:00
|
|
|
data[:ref],
|
|
|
|
data[:before],
|
|
|
|
data[:after],
|
2013-08-19 05:11:36 -04:00
|
|
|
token: token,
|
2018-04-20 07:02:42 -04:00
|
|
|
repo: project.repository,
|
2017-07-20 05:34:09 -04:00
|
|
|
repo_url: "#{Gitlab.config.gitlab.url}/#{project.full_path}",
|
|
|
|
commit_url: "#{Gitlab.config.gitlab.url}/#{project.full_path}/commit/%s",
|
|
|
|
diff_url: "#{Gitlab.config.gitlab.url}/#{project.full_path}/compare/%s...%s"
|
2015-12-14 21:53:52 -05:00
|
|
|
)
|
2013-08-19 05:11:36 -04:00
|
|
|
end
|
|
|
|
end
|