use policies to protect sending email

This commit is contained in:
http://jneen.net/ 2017-02-28 15:24:04 -08:00
parent bb0cba920a
commit f7a111e976
2 changed files with 2 additions and 1 deletions

View file

@ -9,6 +9,7 @@ class GlobalPolicy < BasePolicy
can! :log_in unless @user.access_locked? can! :log_in unless @user.access_locked?
can! :access_api can! :access_api
can! :access_git can! :access_git
can! :receive_notifications
end end
end end
end end

View file

@ -465,7 +465,7 @@ class NotificationService
end end
users = users.to_a.compact.uniq users = users.to_a.compact.uniq
users = users.reject(&:blocked?) users = users.select { |u| u.can?(:receive_notifications) }
users.reject do |user| users.reject do |user|
global_notification_setting = user.global_notification_setting global_notification_setting = user.global_notification_setting