local_notification_worker.rb 598 B

12345678910111213141516171819
  1. # frozen_string_literal: true
  2. class LocalNotificationWorker
  3. include Sidekiq::Worker
  4. def perform(receiver_account_id, activity_id = nil, activity_class_name = nil, type = nil)
  5. if activity_id.nil? && activity_class_name.nil?
  6. activity = Mention.find(receiver_account_id)
  7. receiver = activity.account
  8. else
  9. receiver = Account.find(receiver_account_id)
  10. activity = activity_class_name.constantize.find(activity_id)
  11. end
  12. NotifyService.new.call(receiver, type || activity_class_name.underscore, activity)
  13. rescue ActiveRecord::RecordNotFound
  14. true
  15. end
  16. end