gitlab-org--gitlab-foss/app/models/project_services/flowdock_service.rb

64 lines
1.7 KiB
Ruby
Raw Normal View History

# == Schema Information
#
# Table name: services
#
2015-03-04 17:14:00 -05:00
# id :integer not null, primary key
# type :string(255)
# title :string(255)
# project_id :integer
# created_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
# properties :text
# template :boolean default(FALSE)
# push_events :boolean default(TRUE)
# issues_events :boolean default(TRUE)
# merge_requests_events :boolean default(TRUE)
# tag_push_events :boolean default(TRUE)
2015-05-03 12:05:38 -04:00
# note_events :boolean default(TRUE), not null
#
require "flowdock-git-hook"
class FlowdockService < Service
2014-09-07 20:54:18 -04:00
prop_accessor :token
validates :token, presence: true, if: :activated?
def title
'Flowdock'
end
def description
'Flowdock is a collaboration web app for technical teams.'
end
def to_param
'flowdock'
end
def fields
[
{ type: 'text', name: 'token', placeholder: 'Flowdock Git source token' }
]
end
def supported_events
%w(push)
end
2015-02-20 08:49:26 -05:00
def execute(data)
return unless supported_events.include?(data[:object_kind])
Flowdock::Git.post(
2015-02-20 08:49:26 -05:00
data[:ref],
data[:before],
data[:after],
token: token,
2014-11-05 11:51:08 -05:00
repo: project.repository.path_to_repo,
repo_url: "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}",
commit_url: "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/commit/%s",
diff_url: "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/compare/%s...%s",
2015-12-14 21:53:52 -05:00
)
end
end