gab-social/app/workers/web/push_notification_worker.rb
mgabdev 56d0698536 Added max retry to 3 on PushNotificationWorker
• Added:
- max retry to 3 on PushNotificationWorker
2020-07-14 00:21:46 -05:00

19 lines
538 B
Ruby

# frozen_string_literal: true
class Web::PushNotificationWorker
include Sidekiq::Worker
sidekiq_options backtrace: true, retry: 3
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