summaryrefslogtreecommitdiff
path: root/app/services
diff options
context:
space:
mode:
Diffstat (limited to 'app/services')
-rw-r--r--app/services/notification_service.rb13
-rw-r--r--app/services/projects/participants_service.rb28
2 files changed, 19 insertions, 22 deletions
diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb
index cfed7964c37..c7e45a2c2c7 100644
--- a/app/services/notification_service.rb
+++ b/app/services/notification_service.rb
@@ -127,17 +127,12 @@ class NotificationService
recipients = []
- if note.commit_id.present?
- recipients << note.commit_author
- end
-
# Add all users participating in the thread (author, assignee, comment authors)
participants =
- if target.respond_to?(:participants)
- target.participants
- elsif target.is_a?(Commit)
- author_ids = Note.for_commit_id(target.id).pluck(:author_id).uniq
- User.where(id: author_ids)
+ if target.is_a?(Commit)
+ target.participants(note.project, note.author)
+ elsif target.respond_to?(:participants)
+ target.participants(note.author)
else
note.mentioned_users
end
diff --git a/app/services/projects/participants_service.rb b/app/services/projects/participants_service.rb
index ae6260bcdab..c2d8f48f6e4 100644
--- a/app/services/projects/participants_service.rb
+++ b/app/services/projects/participants_service.rb
@@ -13,19 +13,21 @@ module Projects
end
def participants_in(type, id)
- users = case type
- when "Issue"
- issue = project.issues.find_by_iid(id)
- issue ? issue.participants(current_user) : []
- when "MergeRequest"
- merge_request = project.merge_requests.find_by_iid(id)
- merge_request ? merge_request.participants(current_user) : []
- when "Commit"
- author_ids = Note.for_commit_id(id).pluck(:author_id).uniq
- User.where(id: author_ids)
- else
- []
- end
+ users =
+ case type
+ when "Issue"
+ issue = project.issues.find_by_iid(id)
+ issue.participants(current_user) if issue
+ when "MergeRequest"
+ merge_request = project.merge_requests.find_by_iid(id)
+ merge_request.participants(current_user) if merge_request
+ when "Commit"
+ commit = project.repository.commit(id)
+ commit.participants(project, current_user) if commit
+ end
+
+ return [] unless users
+
sorted(users)
end