diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2019-09-13 19:15:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-13 19:15:47 +0200 |
commit | e8703c281e5bf6538f620af1d0b24fdef7de7fc2 (patch) | |
tree | d81c9e578072498a90746768269485c71bb63739 | |
parent | 18331fefa2246facc818226043b1f9cc67cf6c1a (diff) |
Fix web push subscriptions being deleted on rate limit or timeout (#11826)
-rw-r--r-- | app/workers/web/push_notification_worker.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/app/workers/web/push_notification_worker.rb b/app/workers/web/push_notification_worker.rb index 901043975..46aeaa30b 100644 --- a/app/workers/web/push_notification_worker.rb +++ b/app/workers/web/push_notification_worker.rb @@ -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 |