mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-20 14:54:15 +01:00
use an async worker to notify users about policy update
This commit is contained in:
parent
dd4ad1e935
commit
b0b2e8d3a9
@ -51,9 +51,7 @@ class Setting < ActiveRecord::Base
|
|||||||
def notify_privacy_policy_changed
|
def notify_privacy_policy_changed
|
||||||
return unless name == 'privacy_body'
|
return unless name == 'privacy_body'
|
||||||
|
|
||||||
NotificationCenter.call type: :notify_privacy_policy_changed,
|
NotifyPrivacyUpdateWorker.perform_async(id)
|
||||||
receiver: User.all,
|
|
||||||
attached_object: self
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def value
|
def value
|
||||||
|
16
app/workers/notify_privacy_update_worker.rb
Normal file
16
app/workers/notify_privacy_update_worker.rb
Normal 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
|
Loading…
x
Reference in New Issue
Block a user