1
0
mirror of https://github.com/whippyshou/mastodon synced 2024-12-03 17:28:30 +09:00
whippy-edition/app/workers/web/push_notification_worker.rb

19 lines
516 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class Web::PushNotificationWorker
include Sidekiq::Worker
sidekiq_options backtrace: true
def perform(subscription_id, notification_id)
subscription = ::Web::PushSubscription.find(subscription_id)
notification = Notification.find(notification_id)
subscription.push(notification) unless notification.activity.nil?
rescue Webpush::InvalidSubscription, Webpush::ExpiredSubscription
subscription.destroy!
rescue ActiveRecord::RecordNotFound
true
end
end