Skip to content

Commit

Permalink
Fix URLs appearing twice in errors of ActivityPub::DeliveryWorker
Browse files Browse the repository at this point in the history
  • Loading branch information
Gargron committed Jul 7, 2019
1 parent 23aeef5 commit 31b5607
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/lib/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def perform
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
Expand Down
14 changes: 9 additions & 5 deletions app/workers/activitypub/delivery_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ def perform(json, source_account_id, inbox_url, options = {})
@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
Expand All @@ -40,6 +42,8 @@ def perform_request
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
Expand Down

0 comments on commit 31b5607

Please sign in to comment.