diff options
Diffstat (limited to 'app/models/concerns/participable.rb')
-rw-r--r-- | app/models/concerns/participable.rb | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/app/models/concerns/participable.rb b/app/models/concerns/participable.rb index 7c9597333dd..ffc874357fd 100644 --- a/app/models/concerns/participable.rb +++ b/app/models/concerns/participable.rb @@ -37,8 +37,8 @@ module Participable # Be aware that this method makes a lot of sql queries. # Save result into variable if you are going to reuse it inside same request - def participants(current_user = self.author, project = self.project) - participants = self.class.participant_attrs.flat_map do |attr| + def participants(current_user = self.author) + self.class.participant_attrs.flat_map do |attr| meth = method(attr) value = @@ -48,28 +48,22 @@ module Participable meth.call end - participants_for(value, current_user, project) - end.compact.uniq - - if project - participants.select! do |user| - user.can?(:read_project, project) - end + participants_for(value, current_user) + end.compact.uniq.select do |user| + user.can?(:read_project, self.project) end - - participants end private - def participants_for(value, current_user = nil, project = nil) + def participants_for(value, current_user = nil) case value when User [value] when Enumerable, ActiveRecord::Relation - value.flat_map { |v| participants_for(v, current_user, project) } + value.flat_map { |v| participants_for(v, current_user) } when Participable - value.participants(current_user, project) + value.participants(current_user) end end end |