summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/hooks/web_hook.rb16
-rw-r--r--app/models/project.rb2
2 files changed, 12 insertions, 6 deletions
diff --git a/app/models/hooks/web_hook.rb b/app/models/hooks/web_hook.rb
index 315d96af1b9..e9fd441352d 100644
--- a/app/models/hooks/web_hook.rb
+++ b/app/models/hooks/web_hook.rb
@@ -30,12 +30,15 @@ class WebHook < ActiveRecord::Base
validates :url, presence: true,
format: { with: /\A#{URI.regexp(%w(http https))}\z/, message: "should be a valid url" }
- def execute(data)
+ def execute(data, hook_name)
parsed_url = URI.parse(url)
if parsed_url.userinfo.blank?
WebHook.post(url,
body: data.to_json,
- headers: { "Content-Type" => "application/json" },
+ headers: {
+ "Content-Type" => "application/json",
+ "X-Gitlab-Event" => hook_name.singularize.titleize
+ },
verify: false)
else
post_url = url.gsub("#{parsed_url.userinfo}@", "")
@@ -45,7 +48,10 @@ class WebHook < ActiveRecord::Base
}
WebHook.post(post_url,
body: data.to_json,
- headers: { "Content-Type" => "application/json" },
+ headers: {
+ "Content-Type" => "application/json",
+ "X-Gitlab-Event" => hook_name.singularize.titleize
+ },
verify: false,
basic_auth: auth)
end
@@ -54,7 +60,7 @@ class WebHook < ActiveRecord::Base
false
end
- def async_execute(data)
- Sidekiq::Client.enqueue(ProjectWebHookWorker, id, data)
+ def async_execute(data, hook_name)
+ Sidekiq::Client.enqueue(ProjectWebHookWorker, id, data, hook_name)
end
end
diff --git a/app/models/project.rb b/app/models/project.rb
index 293ee04f228..59cca01e084 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -483,7 +483,7 @@ class Project < ActiveRecord::Base
def execute_hooks(data, hooks_scope = :push_hooks)
hooks.send(hooks_scope).each do |hook|
- hook.async_execute(data)
+ hook.async_execute(data, hooks_scope.to_s)
end
end