Only update FASP availability if it actually changed (#38818)

This commit is contained in:
David Roetzel
2026-04-27 15:15:53 +02:00
committed by GitHub
parent 2b93a2211f
commit 2dd630bc58
2 changed files with 12 additions and 7 deletions

View File

@@ -10,10 +10,12 @@ class Fasp::BaseWorker
def with_provider(provider)
return unless provider.confirmed? && provider.available?
yield
rescue *Mastodon::HTTP_CONNECTION_ERRORS
raise if provider.available?
ensure
provider.update_availability!
begin
yield
rescue *Mastodon::HTTP_CONNECTION_ERRORS
raise if provider.available?
ensure
provider.update_availability!
end
end
end

View File

@@ -2,15 +2,18 @@
RSpec.shared_examples 'worker handling fasp delivery failures' do
context 'when provider is not available' do
let(:delivery_last_failed_at) { 1.minute.ago.beginning_of_minute }
before do
provider.update(delivery_last_failed_at: 1.minute.ago)
provider.update(delivery_last_failed_at:)
domain = Addressable::URI.parse(provider.base_url).normalized_host
UnavailableDomain.create!(domain:)
end
it 'does not attempt connecting and does not fail the job' do
it 'does not attempt connecting, does not fail the job and does not update the provider' do
expect { subject }.to_not raise_error
expect(stubbed_request).to_not have_been_made
expect(provider.reload.delivery_last_failed_at).to eq delivery_last_failed_at
end
end