Commit fb7ce7bd authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'fix-mention-notification' into 'master'

Fix Mention notification level.

Fixes internal issue https://dev.gitlab.org/gitlab/gitlabhq/issues/2236.

See merge request !527
parents 5f78601c b73ffbd3
......@@ -131,21 +131,24 @@ class NotificationService
recipients << note.commit_author
end
# Get users who left comment in thread
recipients = recipients.concat(noteable_commenters(note))
# 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)
else
note.mentioned_users
end
recipients = recipients.concat(participants)
# Merge project watchers
recipients = recipients.concat(project_watchers(note.project)).compact.uniq
# Reject users with Mention notification level
recipients = reject_mention_users(recipients, note.project)
# Add explicitly mentioned users
if target.respond_to?(:participants)
recipients = recipients.concat(target.participants)
else
recipients = recipients.concat(note.mentioned_users)
end
# Reject users with Mention notification level, except those mentioned in _this_ note.
recipients = reject_mention_users(recipients - note.mentioned_users, note.project)
recipients = recipients + note.mentioned_users
# Reject mutes users
recipients = reject_muted_users(recipients, note.project)
......@@ -216,18 +219,6 @@ class NotificationService
protected
def noteable_commenters(note)
opts = { noteable_type: note.noteable_type, project_id: note.project_id }
if note.commit_id.present?
opts.merge!(commit_id: note.commit_id)
else
opts.merge!(noteable_id: note.noteable_id)
end
User.where(id: Note.where(opts).pluck(:author_id))
end
# Get project users with WATCH notification level
def project_watchers(project)
project_members = project_member_notification(project)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment