diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2019-07-07 03:37:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-07 03:37:01 +0200 |
commit | 406b46395d6f79e87b286585f6b6867374d198c1 (patch) | |
tree | f2a92d6c5e2b5ce16f4fa70ce7cf791feaa49671 | |
parent | 58276715be8a7e6b518ebd33cd2d4fd82ae81b2c (diff) |
Fix URLs appearing twice in errors of ActivityPub::DeliveryWorker (#11231)
-rw-r--r-- | app/lib/request.rb | 2 | ||||
-rw-r--r-- | app/workers/activitypub/delivery_worker.rb | 14 |
2 files changed, 10 insertions, 6 deletions
diff --git a/app/lib/request.rb b/app/lib/request.rb index 5f7075a3c..322457ad7 100644 --- a/app/lib/request.rb +++ b/app/lib/request.rb @@ -59,7 +59,7 @@ class Request begin response = http_client.public_send(@verb, @url.to_s, @options.merge(headers: headers)) rescue => e - raise e.class, "#{e.message} on #{@url}", e.backtrace[0] + raise e.class, "#{e.message} on #{@url}", e.backtrace end begin diff --git a/app/workers/activitypub/delivery_worker.rb b/app/workers/activitypub/delivery_worker.rb index 818fd8f5d..8b52b8e49 100644 --- a/app/workers/activitypub/delivery_worker.rb +++ b/app/workers/activitypub/delivery_worker.rb @@ -18,13 +18,15 @@ class ActivityPub::DeliveryWorker @source_account = Account.find(source_account_id) @inbox_url = inbox_url @host = Addressable::URI.parse(inbox_url).normalized_site + @performed = false perform_request - - failure_tracker.track_success! - rescue => e - failure_tracker.track_failure! - raise e.class, "Delivery failed for #{inbox_url}: #{e.message}", e.backtrace[0] + ensure + if @performed + failure_tracker.track_success! + else + failure_tracker.track_failure! + end end private @@ -40,6 +42,8 @@ class ActivityPub::DeliveryWorker request_pool.with(@host) do |http_client| build_request(http_client).perform do |response| raise Mastodon::UnexpectedResponseError, response unless response_successful?(response) || response_error_unsalvageable?(response) + + @performed = true end end end |