Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-05-15 13:45:45 +0300
committerDouwe Maan <douwe@gitlab.com>2015-05-15 13:46:52 +0300
commit0b7c4fe0482cbbc480ff363f2037d70fe52125ee (patch)
treed50877b1f7a097070ac94b718b7b0ffacd8cae4b /app/models/concerns/participable.rb
parentfb86ec519c2a9928e207b2d4363cb4d7f1705cba (diff)
Don't include users without project access in participants.
Diffstat (limited to 'app/models/concerns/participable.rb')
-rw-r--r--app/models/concerns/participable.rb20
1 files changed, 14 insertions, 6 deletions
diff --git a/app/models/concerns/participable.rb b/app/models/concerns/participable.rb
index a4832204f7b..9f667f47e0d 100644
--- a/app/models/concerns/participable.rb
+++ b/app/models/concerns/participable.rb
@@ -35,8 +35,8 @@ module Participable
end
end
- def participants(current_user = self.author)
- self.class.participant_attrs.flat_map do |attr|
+ def participants(current_user = self.author, project = self.project)
+ participants = self.class.participant_attrs.flat_map do |attr|
meth = method(attr)
value =
@@ -46,20 +46,28 @@ module Participable
meth.call
end
- participants_for(value, current_user)
+ participants_for(value, current_user, project)
end.compact.uniq
+
+ if project
+ participants.select! do |user|
+ user.can?(:read_project, project)
+ end
+ end
+
+ participants
end
private
- def participants_for(value, current_user = nil)
+ def participants_for(value, current_user = nil, project = nil)
case value
when User
[value]
when Enumerable, ActiveRecord::Relation
- value.flat_map { |v| participants_for(v, current_user) }
+ value.flat_map { |v| participants_for(v, current_user, project) }
when Participable
- value.participants(current_user)
+ value.participants(current_user, project)
end
end
end