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 1, 2019
1 parent 2cfa427 commit a3d0327
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 @@ -52,7 +52,7 @@ def perform
begin
response = http_client.headers(headers).public_send(@verb, @url.to_s, @options)
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 @@ -17,13 +17,15 @@ def perform(json, source_account_id, inbox_url, options = {})
@json = json
@source_account = Account.find(source_account_id)
@inbox_url = inbox_url
@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 @@ -38,6 +40,8 @@ def perform_request
light = Stoplight(@inbox_url) do
build_request.perform do |response|
raise Mastodon::UnexpectedResponseError, response unless response_successful?(response) || response_error_unsalvageable?(response)

@performed = true
end
end

Expand Down

0 comments on commit a3d0327

Please sign in to comment.