about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-04-05 02:32:18 +0200
committerEugen Rochko <eugen@zeonfederated.com>2017-04-05 02:34:33 +0200
commitbda37489ac5c14d18b1bb4290f2a2931dc8728c9 (patch)
treee759e022081d62a5562e34aaa78227caa96886db /app
parented22f65b3cdd84be5face35d82f127fff6a6b077 (diff)
Remove PuSH subscriptions when delivery is answered with a 4xx error
Diffstat (limited to 'app')
-rw-r--r--app/workers/pubsubhubbub/delivery_worker.rb1
1 files changed, 1 insertions, 0 deletions
diff --git a/app/workers/pubsubhubbub/delivery_worker.rb b/app/workers/pubsubhubbub/delivery_worker.rb
index 15005bc80..466def3a8 100644
--- a/app/workers/pubsubhubbub/delivery_worker.rb
+++ b/app/workers/pubsubhubbub/delivery_worker.rb
@@ -22,6 +22,7 @@ class Pubsubhubbub::DeliveryWorker
                    .headers(headers)
                    .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
 
     subscription.touch(:last_successful_delivery_at)