]> cat aescling's git repositories - mastodon.git/commitdiff
Fix web push subscriptions being deleted on rate limit or timeout (#11826)
authorEugen Rochko <eugen@zeonfederated.com>
Fri, 13 Sep 2019 17:15:47 +0000 (19:15 +0200)
committerGitHub <noreply@github.com>
Fri, 13 Sep 2019 17:15:47 +0000 (19:15 +0200)
app/workers/web/push_notification_worker.rb

index 90104397581aacdcf9f21c58f518c1849bc2c6e0..46aeaa30b1d08ea58b5e3532f379ea2ff5c00380 100644 (file)
@@ -11,7 +11,13 @@ class Web::PushNotificationWorker
 
     subscription.push(notification) unless notification.activity.nil?
   rescue Webpush::ResponseError => e
-    subscription.destroy! if (400..499).cover?(e.response.code.to_i)
+    code = e.response.code.to_i
+
+    if (400..499).cover?(code) && ![408, 429].include?(code)
+      subscription.destroy!
+    else
+      raise e
+    end
   rescue ActiveRecord::RecordNotFound
     true
   end