gab-social/app/workers/local_notification_worker.rb

21 lines
568 B
Ruby
Raw Normal View History

2019-07-02 08:10:25 +01:00
# frozen_string_literal: true
class LocalNotificationWorker
include Sidekiq::Worker
2021-02-05 18:25:46 +00:00
sidekiq_options queue: 'default', retry: 3
2019-07-02 08:10:25 +01:00
def perform(receiver_account_id, activity_id = nil, activity_class_name = nil)
2021-02-01 08:43:56 +00:00
return true if activity_id.nil? or activity_class_name.nil?
ActiveRecord::Base.connected_to(role: :writing) do
receiver = Account.find(receiver_account_id)
activity = activity_class_name.constantize.find(activity_id)
2019-07-02 08:10:25 +01:00
NotifyService.new.call(receiver, activity)
end
2019-07-02 08:10:25 +01:00
rescue ActiveRecord::RecordNotFound
true
end
end