diff --git a/app/workers/bootstrap_timeline_worker.rb b/app/workers/bootstrap_timeline_worker.rb index 89cfb4c3..37cbf222 100644 --- a/app/workers/bootstrap_timeline_worker.rb +++ b/app/workers/bootstrap_timeline_worker.rb @@ -4,6 +4,8 @@ class BootstrapTimelineWorker include Sidekiq::Worker def perform(account_id) - BootstrapTimelineService.new.call(Account.find(account_id)) + ActiveRecord::Base.connected_to(role: :writing) do + BootstrapTimelineService.new.call(Account.find(account_id)) + end end end diff --git a/app/workers/local_notification_worker.rb b/app/workers/local_notification_worker.rb index 673a235e..8dc0c599 100644 --- a/app/workers/local_notification_worker.rb +++ b/app/workers/local_notification_worker.rb @@ -8,10 +8,12 @@ class LocalNotificationWorker def perform(receiver_account_id, activity_id = nil, activity_class_name = nil) return true if activity_id.nil? or activity_class_name.nil? - receiver = Account.find(receiver_account_id) - activity = activity_class_name.constantize.find(activity_id) + ActiveRecord::Base.connected_to(role: :writing) do + receiver = Account.find(receiver_account_id) + activity = activity_class_name.constantize.find(activity_id) - NotifyService.new.call(receiver, activity) + NotifyService.new.call(receiver, activity) + end rescue ActiveRecord::RecordNotFound true end