about summary refs log tree commit diff
path: root/app/workers/fetch_reply_worker.rb
diff options
context:
space:
mode:
authorFire Demon <firedemon@creature.cafe>2020-08-20 06:21:24 -0500
committerFire Demon <firedemon@creature.cafe>2020-08-30 05:45:19 -0500
commit503319ec8f9c387ba758a5f8ac8d0249c9420c03 (patch)
treefb23f2d1d401dbf61aab688a5dc7db7002a2e880 /app/workers/fetch_reply_worker.rb
parenta1d1ee39f79c5bd836dffa676c938c1d2c5e79ec (diff)
[Federation] Fall back to server representative if fetching a public resource with another local account fails
Diffstat (limited to 'app/workers/fetch_reply_worker.rb')
-rw-r--r--app/workers/fetch_reply_worker.rb13
1 files changed, 7 insertions, 6 deletions
diff --git a/app/workers/fetch_reply_worker.rb b/app/workers/fetch_reply_worker.rb
index b93ac6c7a..67db042fd 100644
--- a/app/workers/fetch_reply_worker.rb
+++ b/app/workers/fetch_reply_worker.rb
@@ -6,11 +6,12 @@ class FetchReplyWorker
 
   sidekiq_options queue: 'pull', retry: 3
 
-  def perform(child_url)
-    if child_url.is_a?(String)
-      FetchRemoteStatusService.new.call(child_url, nil)
-    elsif child_url.is_a?(Enumerable)
-      child_url.each { |url| FetchRemoteStatusService.new.call(url, nil) }
-    end
+  def perform(child_url, account_id = nil)
+    account = account_id.blank? ? nil : Account.find_by(id: account_id)
+    on_behalf_of = account.blank? ? nil : account.followers.local.random.first
+
+    FetchRemoteStatusService.new.call(child_url, nil, on_behalf_of)
+  rescue ActiveRecord::RecordNotFound
+    nil
   end
 end