浏览代码

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

master^2
Eugen Rochko 4 年前
committed by GitHub
父节点
当前提交
e8703c281e
找不到此签名对应的密钥 GPG 密钥 ID: 4AEE18F83AFDEB23
共有 1 个文件被更改,包括 7 次插入1 次删除
  1. +7
    -1
      app/workers/web/push_notification_worker.rb

+ 7
- 1
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


正在加载...
取消
保存