A platform for community discussion. Free, open, simple.
FIX: Clean up push subscriptions whose endpoint domain no longer resolves (#39804)
Rafael dos Santos Silva51ef930d1fef
diff --git a/app/services/push_notification_pusher.rb b/app/services/push_notification_pusher.rbindex 791147b5057..c1dad02d62f 100644--- a/app/services/push_notification_pusher.rb+++ b/app/services/push_notification_pusher.rb@@ -182,6 +182,9 @@ class PushNotificationPusherhandle_generic_error(subscription, e, user, endpoint, message)rescue OpenSSL::SSL::SSLError => ehandle_generic_error(subscription, e, user, endpoint, message)+ rescue FinalDestination::SSRFDetector::LookupFailedError,+ FinalDestination::SSRFDetector::DisallowedIpError => e+ handle_generic_error(subscription, e, user, endpoint, message)endenddiff --git a/spec/services/push_notification_pusher_spec.rb b/spec/services/push_notification_pusher_spec.rbindex eba35973767..6e2d8ed9ea0 100644--- a/spec/services/push_notification_pusher_spec.rb+++ b/spec/services/push_notification_pusher_spec.rb@@ -228,6 +228,30 @@ RSpec.describe PushNotificationPusher doexpect(subscription.error_count).to eq(1)end+ it "handles DNS lookup failures for endpoints whose domain no longer resolves" do+ WebPush.expects(:payload_send).raises(+ FinalDestination::SSRFDetector::LookupFailedError.new("lookup failed"),+ )+ subscription = create_subscription++ expect { execute_push }.to_not raise_exception++ subscription.reload+ expect(subscription.error_count).to eq(1)+ end++ it "handles endpoints that resolve to disallowed IPs" do+ WebPush.expects(:payload_send).raises(+ FinalDestination::SSRFDetector::DisallowedIpError.new("disallowed"),+ )+ subscription = create_subscription++ expect { execute_push }.to_not raise_exception++ subscription.reload+ expect(subscription.error_count).to eq(1)+ end+describe "`watching_category_or_tag` notifications" doit "Uses the 'watching_first_post' translation when new topic was created" domessage =