Fix URLs appearing twice in errors of ActivityPub::DeliveryWorker (#11231)

shrike
Eugen Rochko 2019-07-07 03:37:01 +02:00 committed by GitHub
parent 58276715be
commit 406b46395d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions

View File

@ -59,7 +59,7 @@ class Request
begin begin
response = http_client.public_send(@verb, @url.to_s, @options.merge(headers: headers)) response = http_client.public_send(@verb, @url.to_s, @options.merge(headers: headers))
rescue => e rescue => e
raise e.class, "#{e.message} on #{@url}", e.backtrace[0] raise e.class, "#{e.message} on #{@url}", e.backtrace
end end
begin begin

View File

@ -18,13 +18,15 @@ class ActivityPub::DeliveryWorker
@source_account = Account.find(source_account_id) @source_account = Account.find(source_account_id)
@inbox_url = inbox_url @inbox_url = inbox_url
@host = Addressable::URI.parse(inbox_url).normalized_site @host = Addressable::URI.parse(inbox_url).normalized_site
@performed = false
perform_request perform_request
ensure
if @performed
failure_tracker.track_success! failure_tracker.track_success!
rescue => e else
failure_tracker.track_failure! failure_tracker.track_failure!
raise e.class, "Delivery failed for #{inbox_url}: #{e.message}", e.backtrace[0] end
end end
private private
@ -40,6 +42,8 @@ class ActivityPub::DeliveryWorker
request_pool.with(@host) do |http_client| request_pool.with(@host) do |http_client|
build_request(http_client).perform do |response| build_request(http_client).perform do |response|
raise Mastodon::UnexpectedResponseError, response unless response_successful?(response) || response_error_unsalvageable?(response) raise Mastodon::UnexpectedResponseError, response unless response_successful?(response) || response_error_unsalvageable?(response)
@performed = true
end end
end end
end end