Skip to content
Permalink
Browse files

Fix web push subscriptions being deleted on rate limit or timeout (#1…

  • Loading branch information...
Gargron committed Sep 13, 2019
1 parent 18331fe commit e8703c281e5bf6538f620af1d0b24fdef7de7fc2
Showing with 7 additions and 1 deletion.
  1. +7 −1 app/workers/web/push_notification_worker.rb
@@ -11,7 +11,13 @@ def perform(subscription_id, notification_id)

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

0 comments on commit e8703c2

Please sign in to comment.
You can’t perform that action at this time.