Remove PuSH subscriptions when delivery is answered with a 4xx error

remotes/1727458204337373841/tmp_refs/heads/signup-info-prompt
Eugen Rochko 2017-04-05 02:32:18 +02:00
parent ed22f65b3c
commit bda37489ac
1 changed files with 1 additions and 0 deletions

View File

@ -22,6 +22,7 @@ class Pubsubhubbub::DeliveryWorker
.headers(headers) .headers(headers)
.post(subscription.callback_url, body: payload) .post(subscription.callback_url, body: payload)
return subscription.destroy! if response.code > 299 && response.code < 500 && response.code != 429 # HTTP 4xx means error is not temporary, except for 429 (throttling)
raise "Delivery failed for #{subscription.callback_url}: HTTP #{response.code}" unless response.code > 199 && response.code < 300 raise "Delivery failed for #{subscription.callback_url}: HTTP #{response.code}" unless response.code > 199 && response.code < 300
subscription.touch(:last_successful_delivery_at) subscription.touch(:last_successful_delivery_at)