Browse Source

Do no retry web push workers if the server returns a 4xx response (#9434)

Add timeout of 10s to web push requests
pull/4/head
Eugen Rochko 5 years ago
committed by GitHub
parent
commit
628da11e38
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions
  1. +3
    -0
      app/models/web/push_subscription.rb
  2. +2
    -2
      app/workers/web/push_notification_worker.rb

+ 3
- 0
app/models/web/push_subscription.rb View File

@ -68,6 +68,9 @@ class Web::PushSubscription < ApplicationRecord
p256dh: key_p256dh,
auth: key_auth,
ttl: ttl,
ssl_timeout: 10,
open_timeout: 10,
read_timeout: 10,
vapid: {
subject: "mailto:#{::Setting.site_contact_email}",
private_key: Rails.configuration.x.vapid_private_key,

+ 2
- 2
app/workers/web/push_notification_worker.rb View File

@ -10,8 +10,8 @@ class Web::PushNotificationWorker
notification = Notification.find(notification_id)
subscription.push(notification) unless notification.activity.nil?
rescue Webpush::InvalidSubscription, Webpush::ExpiredSubscription
subscription.destroy!
rescue Webpush::ResponseError => e
subscription.destroy! if (400..499).cover?(e.response.code.to_i)
rescue ActiveRecord::RecordNotFound
true
end

Loading…
Cancel
Save