1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-17 11:54:22 +01:00

use an async worker to notify users about policy update

This commit is contained in:
Sylvain 2019-06-17 10:01:59 +02:00
parent dd4ad1e935
commit b0b2e8d3a9
2 changed files with 17 additions and 3 deletions

View File

@ -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

View File

@ -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