summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-08-30 19:11:46 -0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-08-31 18:34:45 -0300
commit21f10af0956c69b6a5bad6b36b7d6e12e60e7867 (patch)
treeb67fa1c084a144f89559e14b0be5c5a0e7421c76 /app
parentdd64f8aaf867516043dbbf559595a0ed9671ab3b (diff)
downloadgitlab-ce-21f10af0956c69b6a5bad6b36b7d6e12e60e7867.tar.gz
Scope hooks thal will run for confidential issues
Diffstat (limited to 'app')
-rw-r--r--app/models/hooks/project_hook.rb1
-rw-r--r--app/models/service.rb1
-rw-r--r--app/services/issues/base_service.rb9
3 files changed, 6 insertions, 5 deletions
diff --git a/app/models/hooks/project_hook.rb b/app/models/hooks/project_hook.rb
index 836a75b0608..c631e7a7df5 100644
--- a/app/models/hooks/project_hook.rb
+++ b/app/models/hooks/project_hook.rb
@@ -2,6 +2,7 @@ class ProjectHook < WebHook
belongs_to :project
scope :issue_hooks, -> { where(issues_events: true) }
+ scope :confidential_issue_hooks, -> { where(confidential_issues_events: true) }
scope :note_hooks, -> { where(note_events: true) }
scope :merge_request_hooks, -> { where(merge_requests_events: true) }
scope :build_hooks, -> { where(build_events: true) }
diff --git a/app/models/service.rb b/app/models/service.rb
index 7333f8d381b..198e7247838 100644
--- a/app/models/service.rb
+++ b/app/models/service.rb
@@ -34,6 +34,7 @@ class Service < ActiveRecord::Base
scope :push_hooks, -> { where(push_events: true, active: true) }
scope :tag_push_hooks, -> { where(tag_push_events: true, active: true) }
scope :issue_hooks, -> { where(issues_events: true, active: true) }
+ scope :confidential_issue_hooks, -> { where(confidential_issues_events: true, active: true) }
scope :merge_request_hooks, -> { where(merge_requests_events: true, active: true) }
scope :note_hooks, -> { where(note_events: true, active: true) }
scope :build_hooks, -> { where(build_events: true, active: true) }
diff --git a/app/services/issues/base_service.rb b/app/services/issues/base_service.rb
index 241efc44d36..9ea3ce084ba 100644
--- a/app/services/issues/base_service.rb
+++ b/app/services/issues/base_service.rb
@@ -14,11 +14,10 @@ module Issues
end
def execute_hooks(issue, action = 'open')
- return if issue.confidential?
-
- issue_data = hook_data(issue, action)
- issue.project.execute_hooks(issue_data, :issue_hooks)
- issue.project.execute_services(issue_data, :issue_hooks)
+ issue_data = hook_data(issue, action)
+ hooks_scope = issue.confidential? ? :confidential_issue_hooks : :issue_hooks
+ issue.project.execute_hooks(issue_data, hooks_scope)
+ issue.project.execute_services(issue_data, hooks_scope)
end
end
end