]> cat aescling's git repositories - mastodon.git/commitdiff
Do no retry web push workers if the server returns a 4xx response (#9434)
authorEugen Rochko <eugen@zeonfederated.com>
Mon, 17 Dec 2018 02:14:13 +0000 (03:14 +0100)
committerGitHub <noreply@github.com>
Mon, 17 Dec 2018 02:14:13 +0000 (03:14 +0100)
Add timeout of 10s to web push requests

app/models/web/push_subscription.rb
app/workers/web/push_notification_worker.rb

index d19b20c483f66f0adbc7e10653b0bf370fc12680..b57807d1c2bd5a38144cc617d4911eaabeeb5e97 100644 (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,
index 4a40e5c8bd98f49f1e7e8a281cad23fa9831fb00..8e8a359735674ea753a6b0fed60b5ab71f90cf9a 100644 (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