2018-11-20 20:47:30 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
class FlowdockService < Integration
|
|
|
|
include ActionView::Helpers::UrlHelper
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
prop_accessor :token
|
2014-09-02 18:07:02 +05:30
|
|
|
validates :token, presence: true, if: :activated?
|
|
|
|
|
|
|
|
def title
|
|
|
|
'Flowdock'
|
|
|
|
end
|
|
|
|
|
|
|
|
def description
|
2021-06-08 01:23:25 +05:30
|
|
|
s_('FlowdockService|Send event notifications from GitLab to Flowdock flows.')
|
|
|
|
end
|
|
|
|
|
|
|
|
def help
|
|
|
|
docs_link = link_to _('Learn more.'), Rails.application.routes.url_helpers.help_page_url('api/services', anchor: 'flowdock'), target: '_blank', rel: 'noopener noreferrer'
|
|
|
|
s_('FlowdockService|Send event notifications from GitLab to Flowdock flows. %{docs_link}').html_safe % { docs_link: docs_link.html_safe }
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
def self.to_param
|
2014-09-02 18:07:02 +05:30
|
|
|
'flowdock'
|
|
|
|
end
|
|
|
|
|
|
|
|
def fields
|
|
|
|
[
|
2021-06-08 01:23:25 +05:30
|
|
|
{ type: 'text', name: 'token', placeholder: s_('FlowdockService|1b609b52537...'), required: true, help: 'Enter your Flowdock token.' }
|
2014-09-02 18:07:02 +05:30
|
|
|
]
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
def self.supported_events
|
2015-04-26 12:48:37 +05:30
|
|
|
%w(push)
|
|
|
|
end
|
|
|
|
|
|
|
|
def execute(data)
|
|
|
|
return unless supported_events.include?(data[:object_kind])
|
|
|
|
|
2014-09-02 18:07:02 +05:30
|
|
|
Flowdock::Git.post(
|
2015-04-26 12:48:37 +05:30
|
|
|
data[:ref],
|
|
|
|
data[:before],
|
|
|
|
data[:after],
|
2014-09-02 18:07:02 +05:30
|
|
|
token: token,
|
2018-10-15 14:42:47 +05:30
|
|
|
repo: project.repository,
|
2017-09-10 17:25:29 +05:30
|
|
|
repo_url: "#{Gitlab.config.gitlab.url}/#{project.full_path}",
|
2020-03-13 15:44:24 +05:30
|
|
|
commit_url: "#{Gitlab.config.gitlab.url}/#{project.full_path}/-/commit/%s",
|
2017-09-10 17:25:29 +05:30
|
|
|
diff_url: "#{Gitlab.config.gitlab.url}/#{project.full_path}/compare/%s...%s"
|
2015-12-23 02:04:40 +05:30
|
|
|
)
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
end
|