summaryrefslogtreecommitdiff
path: root/app/models/hooks
diff options
context:
space:
mode:
authorbugagazavr <kirik910@gmail.com>2015-01-24 03:10:43 +0300
committerKirill Zaitsev <kirik910@gmail.com>2015-04-25 21:31:52 +0300
commit548f182814acd0f7a110e6c165c186e345901b00 (patch)
tree26bb991cb343dd48c81f1004016817e634ee5039 /app/models/hooks
parent5cb325b50188fb2ba6483e710a29350c4b0b06ae (diff)
downloadgitlab-ce-548f182814acd0f7a110e6c165c186e345901b00.tar.gz
Added X-GitLab-Event header for web hooks
Diffstat (limited to 'app/models/hooks')
-rw-r--r--app/models/hooks/web_hook.rb16
1 files changed, 11 insertions, 5 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