diff --git a/app/models/setting.rb b/app/models/setting.rb index 8e07e6535..517c2b912 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -51,9 +51,7 @@ class Setting < ActiveRecord::Base def notify_privacy_policy_changed return unless name == 'privacy_body' - NotificationCenter.call type: :notify_privacy_policy_changed, - receiver: User.all, - attached_object: self + NotifyPrivacyUpdateWorker.perform_async(id) end def value diff --git a/app/workers/notify_privacy_update_worker.rb b/app/workers/notify_privacy_update_worker.rb new file mode 100644 index 000000000..7e1266309 --- /dev/null +++ b/app/workers/notify_privacy_update_worker.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +# Send an email to all users (with role member) in the database to alert them about a privacy policy change +class NotifyPrivacyUpdateWorker + include Sidekiq::Worker + + def perform(setting_id) + setting = Setting.find(setting_id) + + # notify all users + NotificationCenter.call type: :notify_privacy_policy_changed, + receiver: User.with_role(:member).all, + attached_object: setting + end + +end