diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2019-07-10 18:59:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-10 18:59:28 +0200 |
commit | 5d3feed191bcbe2769512119752b426108152fe9 (patch) | |
tree | b36bc69823e5a16250bb9f72d388498737d6725a /app/workers/activitypub | |
parent | d04c584159fdad36d7713718c4ba0b3b42cd27a9 (diff) |
Refactor fetching of remote resources (#11251)
Diffstat (limited to 'app/workers/activitypub')
-rw-r--r-- | app/workers/activitypub/delivery_worker.rb | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/app/workers/activitypub/delivery_worker.rb b/app/workers/activitypub/delivery_worker.rb index 8b52b8e49..5457d9d4b 100644 --- a/app/workers/activitypub/delivery_worker.rb +++ b/app/workers/activitypub/delivery_worker.rb @@ -2,6 +2,7 @@ class ActivityPub::DeliveryWorker include Sidekiq::Worker + include JsonLdHelper STOPLIGHT_FAILURE_THRESHOLD = 10 STOPLIGHT_COOLDOWN = 60 @@ -32,9 +33,10 @@ class ActivityPub::DeliveryWorker private def build_request(http_client) - request = Request.new(:post, @inbox_url, body: @json, http_client: http_client) - request.on_behalf_of(@source_account, :uri, sign_with: @options[:sign_with]) - request.add_headers(HEADERS) + Request.new(:post, @inbox_url, body: @json, http_client: http_client).tap do |request| + request.on_behalf_of(@source_account, :uri, sign_with: @options[:sign_with]) + request.add_headers(HEADERS) + end end def perform_request @@ -53,14 +55,6 @@ class ActivityPub::DeliveryWorker .run end - def response_successful?(response) - (200...300).cover?(response.code) - end - - def response_error_unsalvageable?(response) - response.code == 501 || ((400...500).cover?(response.code) && ![401, 408, 429].include?(response.code)) - end - def failure_tracker @failure_tracker ||= DeliveryFailureTracker.new(@inbox_url) end |