2018-05-03 05:10:57 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class LocalNotificationWorker
|
|
|
|
include Sidekiq::Worker
|
|
|
|
|
2020-09-19 00:26:45 +09:00
|
|
|
def perform(receiver_account_id, activity_id = nil, activity_class_name = nil, type = nil)
|
2018-11-09 05:05:42 +09:00
|
|
|
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
|
|
|
|
|
2022-01-20 06:37:27 +09:00
|
|
|
return if Notification.where(account: receiver, activity: activity).any?
|
|
|
|
|
2020-09-19 00:26:45 +09:00
|
|
|
NotifyService.new.call(receiver, type || activity_class_name.underscore, activity)
|
2018-05-03 05:10:57 +09:00
|
|
|
rescue ActiveRecord::RecordNotFound
|
|
|
|
true
|
|
|
|
end
|
|
|
|
end
|