mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-26 22:36:21 +01:00
Do no retry web push workers if the server returns a 4xx response (#9434)
Add timeout of 10s to web push requests
This commit is contained in:
parent
4297de34cf
commit
628da11e38
@ -68,6 +68,9 @@ class Web::PushSubscription < ApplicationRecord
|
|||||||
p256dh: key_p256dh,
|
p256dh: key_p256dh,
|
||||||
auth: key_auth,
|
auth: key_auth,
|
||||||
ttl: ttl,
|
ttl: ttl,
|
||||||
|
ssl_timeout: 10,
|
||||||
|
open_timeout: 10,
|
||||||
|
read_timeout: 10,
|
||||||
vapid: {
|
vapid: {
|
||||||
subject: "mailto:#{::Setting.site_contact_email}",
|
subject: "mailto:#{::Setting.site_contact_email}",
|
||||||
private_key: Rails.configuration.x.vapid_private_key,
|
private_key: Rails.configuration.x.vapid_private_key,
|
||||||
|
@ -10,8 +10,8 @@ class Web::PushNotificationWorker
|
|||||||
notification = Notification.find(notification_id)
|
notification = Notification.find(notification_id)
|
||||||
|
|
||||||
subscription.push(notification) unless notification.activity.nil?
|
subscription.push(notification) unless notification.activity.nil?
|
||||||
rescue Webpush::InvalidSubscription, Webpush::ExpiredSubscription
|
rescue Webpush::ResponseError => e
|
||||||
subscription.destroy!
|
subscription.destroy! if (400..499).cover?(e.response.code.to_i)
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user