mirror of
https://github.com/glitch-soc/mastodon.git
synced 2024-11-24 17:14:15 -05:00
628da11e38
Add timeout of 10s to web push requests
19 lines
528 B
Ruby
19 lines
528 B
Ruby
# 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
|