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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 7 deletions

View File

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

View File

@ -2,15 +2,18 @@
RSpec.shared_examples 'worker handling fasp delivery failures' do RSpec.shared_examples 'worker handling fasp delivery failures' do
context 'when provider is not available' do context 'when provider is not available' do
let(:delivery_last_failed_at) { 1.minute.ago.beginning_of_minute }
before do 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 domain = Addressable::URI.parse(provider.base_url).normalized_host
UnavailableDomain.create!(domain:) UnavailableDomain.create!(domain:)
end 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 { subject }.to_not raise_error
expect(stubbed_request).to_not have_been_made expect(stubbed_request).to_not have_been_made
expect(provider.reload.delivery_last_failed_at).to eq delivery_last_failed_at
end end
end end