Merge branch 'sys_hooks' of dev.gitlabhq.com:gitlabhq
This commit is contained in:
commit
3c6daec4b1
33 changed files with 425 additions and 133 deletions
|
@ -19,7 +19,7 @@ class Project < ActiveRecord::Base
|
|||
has_many :notes, :dependent => :destroy
|
||||
has_many :snippets, :dependent => :destroy
|
||||
has_many :deploy_keys, :dependent => :destroy, :foreign_key => "project_id", :class_name => "Key"
|
||||
has_many :web_hooks, :dependent => :destroy
|
||||
has_many :hooks, :dependent => :destroy, :class_name => "ProjectHook"
|
||||
has_many :wikis, :dependent => :destroy
|
||||
has_many :protected_branches, :dependent => :destroy
|
||||
|
||||
|
@ -120,7 +120,7 @@ class Project < ActiveRecord::Base
|
|||
errors.add(:path, " like 'gitolite-admin' is not allowed")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def self.access_options
|
||||
UsersProject.access_roles
|
||||
end
|
||||
|
|
3
app/models/project_hook.rb
Normal file
3
app/models/project_hook.rb
Normal file
|
@ -0,0 +1,3 @@
|
|||
class ProjectHook < WebHook
|
||||
belongs_to :project
|
||||
end
|
13
app/models/system_hook.rb
Normal file
13
app/models/system_hook.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
class SystemHook < WebHook
|
||||
|
||||
def async_execute(data)
|
||||
Resque.enqueue(SystemHookWorker, id, data)
|
||||
end
|
||||
|
||||
def self.all_hooks_fire(data)
|
||||
SystemHook.all.each do |sh|
|
||||
sh.async_execute data
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -1,4 +1,5 @@
|
|||
class User < ActiveRecord::Base
|
||||
|
||||
include Account
|
||||
|
||||
devise :database_authenticatable, :token_authenticatable, :lockable,
|
||||
|
|
|
@ -68,7 +68,7 @@ class UsersProject < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def repo_access_human
|
||||
""
|
||||
self.class.access_roles.invert[self.project_access]
|
||||
end
|
||||
end
|
||||
# == Schema Information
|
||||
|
|
|
@ -4,8 +4,6 @@ class WebHook < ActiveRecord::Base
|
|||
# HTTParty timeout
|
||||
default_timeout 10
|
||||
|
||||
belongs_to :project
|
||||
|
||||
validates :url,
|
||||
presence: true,
|
||||
format: {
|
||||
|
@ -14,9 +12,8 @@ class WebHook < ActiveRecord::Base
|
|||
|
||||
def execute(data)
|
||||
WebHook.post(url, body: data.to_json, headers: { "Content-Type" => "application/json" })
|
||||
rescue
|
||||
# There was a problem calling this web hook, let's forget about it.
|
||||
end
|
||||
|
||||
end
|
||||
# == Schema Information
|
||||
#
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue