about summary refs log tree commit diff
path: root/app/workers/local_notification_worker.rb
blob: 48635e498fffd7e09893fd25ec92d509da241f0e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

class LocalNotificationWorker
  include Sidekiq::Worker

  def perform(receiver_account_id, activity_id = nil, activity_class_name = nil)
    if activity_id.nil? && activity_class_name.nil?
      activity = Mention.find(receiver_account_id)
      receiver = activity.account
    else
      receiver = Account.find(receiver_account_id)
      activity = activity_class_name.constantize.find(activity_id)
    end

    NotifyService.new.call(receiver, activity)
  rescue ActiveRecord::RecordNotFound
    true
  end
end