You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
528 B
18 lines
528 B
# 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::ResponseError => e |
|
subscription.destroy! if (400..499).cover?(e.response.code.to_i) |
|
rescue ActiveRecord::RecordNotFound |
|
true |
|
end |
|
end
|
|
|