gearheads
/
mastodon
Archived
2
0
Fork 0

Fix web push subscriptions being deleted on rate limit or timeout (#11826)

gh/stable
Eugen Rochko 2019-09-13 19:15:47 +02:00 committed by GitHub
parent 18331fefa2
commit e8703c281e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View 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