BigW Consortium Gitlab

Commit 25951b91 by Dmitriy Zaporozhets

Prepare ProjectHooks to work with issues and merge_requests

* Add event scopes to ProjectHook * Added Issuable#to_hook_data * Project#execute_hooks now accept hook filter as argument Signed-off-by: 's avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 0687ecb6
......@@ -111,4 +111,11 @@ module Issuable
end
users.concat(mentions.reduce([], :|)).uniq
end
def to_hook_data
{
object_kind: self.class.name.underscore,
object_attributes: self.attributes
}
end
end
......@@ -298,8 +298,10 @@ class Project < ActiveRecord::Base
ProjectTransferService.new.transfer(self, new_namespace)
end
def execute_hooks(data)
hooks.each { |hook| hook.async_execute(data) }
def execute_hooks(data, hooks_scope = :push_hooks)
hooks.send(hooks_scope).each do |hook|
hook.async_execute(data)
end
end
def execute_services(data)
......
......@@ -15,4 +15,8 @@ class ProjectHook < WebHook
belongs_to :project
attr_accessible :push_events, :issues_events, :merge_requests_events
scope :push_hooks, -> { where(push_events: true) }
scope :issue_hooks, -> { where(issues_events: true) }
scope :merge_request_hooks, -> { where(merge_requests_events: true) }
end
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