summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Derichs <pderichs@gitlab.com>2019-03-03 18:10:21 +0100
committerPatrick Derichs <pderichs@gitlab.com>2019-03-03 18:10:21 +0100
commitb4ee9d459b8835fce7ddf9a43acae64ddc252fad (patch)
tree73e86ba558b81d21792c072806028da325d55709
parentce2ef436cf0c3221e0974ab86cd06552e76b5964 (diff)
downloadgitlab-ce-fix-extra-emails-notification-recipient-solution.tar.gz
Filtering is done on NotificationRecipient notifiable? methodfix-extra-emails-notification-recipient-solution
-rw-r--r--app/models/notification_recipient.rb4
-rw-r--r--app/services/notification_recipient_service.rb13
2 files changed, 10 insertions, 7 deletions
diff --git a/app/models/notification_recipient.rb b/app/models/notification_recipient.rb
index 481c1d963c6..3a7c74608ab 100644
--- a/app/models/notification_recipient.rb
+++ b/app/models/notification_recipient.rb
@@ -42,6 +42,10 @@ class NotificationRecipient
# except if they were mentioned.
return false if @type != :mention && unsubscribed?
+ if notification_level == :participating && @target.instance_of?(Issue)
+ return @target.mentioned_users.pluck(:id).include?(@user.id)
+ end
+
true
end
diff --git a/app/services/notification_recipient_service.rb b/app/services/notification_recipient_service.rb
index c6ead54af60..56f11b31110 100644
--- a/app/services/notification_recipient_service.rb
+++ b/app/services/notification_recipient_service.rb
@@ -121,12 +121,12 @@ module NotificationRecipientService
# Get project/group users with CUSTOM notification level
# rubocop: disable CodeReuse/ActiveRecord
- def add_custom_notifications(action)
+ def add_custom_notifications
user_ids = []
# Users with a notification setting on group or project
- user_ids += user_ids_notifiable_on(project, :custom, action)
- user_ids += user_ids_notifiable_on(group, :custom, action)
+ user_ids += user_ids_notifiable_on(project, :custom)
+ user_ids += user_ids_notifiable_on(group, :custom)
# Users with global level custom
user_ids_with_project_level_global = user_ids_notifiable_on(project, :global)
@@ -181,14 +181,13 @@ module NotificationRecipientService
end
# rubocop: disable CodeReuse/ActiveRecord
- def user_ids_notifiable_on(resource, notification_level = nil, action = nil)
+ def user_ids_notifiable_on(resource, notification_level = nil)
return [] unless resource
scope = resource.notification_settings
if notification_level
scope = scope.where(level: NotificationSetting.levels[notification_level])
- scope = scope.select { |setting| setting.event_enabled?(action) } if action.present?
end
scope.pluck(:user_id)
@@ -267,7 +266,7 @@ module NotificationRecipientService
def build!
add_participants(current_user)
add_watchers
- add_custom_notifications(custom_action)
+ add_custom_notifications
# Re-assign is considered as a mention of the new assignee
case custom_action
@@ -357,7 +356,7 @@ module NotificationRecipientService
add_group_watchers
end
- add_custom_notifications(custom_action)
+ add_custom_notifications
add_subscribed_users
end