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:
Diffstat (limited to 'app/services/projects/participants_service.rb')
-rw-r--r--app/services/projects/participants_service.rb41
1 files changed, 12 insertions, 29 deletions
diff --git a/app/services/projects/participants_service.rb b/app/services/projects/participants_service.rb
index 1c8f2913e8b..d38328403c1 100644
--- a/app/services/projects/participants_service.rb
+++ b/app/services/projects/participants_service.rb
@@ -1,45 +1,28 @@
module Projects
class ParticipantsService < BaseService
- attr_reader :noteable_type, :noteable_id
-
- def execute
- @noteable_type = params[:type]
- @noteable_id = params[:type_id]
+ attr_reader :noteable
+
+ def execute(noteable)
+ @noteable = noteable
project_members = sorted(project.team.members)
- participants = target_owner + participants_in_target + all_members + groups + project_members
+ participants = noteable_owner + participants_in_noteable + all_members + groups + project_members
participants.uniq
end
- def target
- @target ||=
- case noteable_type
- when 'Issue'
- IssuesFinder.new(current_user, project_id: project.id, state: 'all').
- execute.find_by(iid: noteable_id)
- when 'MergeRequest'
- MergeRequestsFinder.new(current_user, project_id: project.id, state: 'all').
- execute.find_by(iid: noteable_id)
- when 'Commit'
- project.commit(noteable_id)
- else
- nil
- end
- end
-
- def target_owner
- return [] unless target && target.author.present?
+ def noteable_owner
+ return [] unless noteable && noteable.author.present?
[{
- name: target.author.name,
- username: target.author.username
+ name: noteable.author.name,
+ username: noteable.author.username
}]
end
- def participants_in_target
- return [] unless target
+ def participants_in_noteable
+ return [] unless noteable
- users = target.participants(current_user)
+ users = noteable.participants(current_user)
sorted(users)
end