summaryrefslogtreecommitdiff
path: root/app/models/event.rb
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2018-09-21 16:16:13 +0100
committerNick Thomas <nick@gitlab.com>2018-09-21 17:05:08 +0100
commit3214277f3350425baf26b514f1bcf1633018a644 (patch)
treef56a81f160944709dfed3f83477bda8c224dd7d2 /app/models/event.rb
parente5f83afc60439d5b22a8604d6429218ff9ddf4c2 (diff)
downloadgitlab-ce-3214277f3350425baf26b514f1bcf1633018a644.tar.gz
Check snippet note event visibility
Diffstat (limited to 'app/models/event.rb')
-rw-r--r--app/models/event.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/app/models/event.rb b/app/models/event.rb
index 2d9097a7769..2e690f8c013 100644
--- a/app/models/event.rb
+++ b/app/models/event.rb
@@ -148,6 +148,8 @@ class Event < ActiveRecord::Base
end
end
+ # rubocop:disable Metrics/CyclomaticComplexity
+ # rubocop:disable Metrics/PerceivedComplexity
def visible_to_user?(user = nil)
if push? || commit_note?
Ability.allowed?(user, :download_code, project)
@@ -159,12 +161,18 @@ class Event < ActiveRecord::Base
Ability.allowed?(user, :read_issue, note? ? note_target : target)
elsif merge_request? || merge_request_note?
Ability.allowed?(user, :read_merge_request, note? ? note_target : target)
+ elsif personal_snippet_note?
+ Ability.allowed?(user, :read_personal_snippet, note_target)
+ elsif project_snippet_note?
+ Ability.allowed?(user, :read_project_snippet, note_target)
elsif milestone?
Ability.allowed?(user, :read_milestone, project)
else
false # No other event types are visible
end
end
+ # rubocop:enable Metrics/PerceivedComplexity
+ # rubocop:enable Metrics/CyclomaticComplexity
def project_name
if project
@@ -306,6 +314,10 @@ class Event < ActiveRecord::Base
note? && target && target.for_snippet?
end
+ def personal_snippet_note?
+ note? && target && target.for_personal_snippet?
+ end
+
def note_target
target.noteable
end