about summary refs log tree commit diff
path: root/app/workers
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-01-17 10:01:02 +0100
committerGitHub <noreply@github.com>2022-01-17 10:01:02 +0100
commit430d4427916b44e6a7c16db1899dfef2eec140fc (patch)
treee53417f50f9e4ab4b95bf0e9fbb18b0e00b0ce7e /app/workers
parenta85912b0d6d2ee68aa35794fbb51c5358768c092 (diff)
parent77dd4ab8f5d09b128db1e0227b2afcf73d8531e7 (diff)
Merge pull request #1661 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/workers')
-rw-r--r--app/workers/remote_account_refresh_worker.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/app/workers/remote_account_refresh_worker.rb b/app/workers/remote_account_refresh_worker.rb
new file mode 100644
index 000000000..9632936b5
--- /dev/null
+++ b/app/workers/remote_account_refresh_worker.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class RemoteAccountRefreshWorker
+  include Sidekiq::Worker
+  include ExponentialBackoff
+  include JsonLdHelper
+
+  sidekiq_options queue: 'pull', retry: 3
+
+  def perform(id)
+    account = Account.find_by(id: id)
+    return if account.nil? || account.local?
+
+    ActivityPub::FetchRemoteAccountService.new.call(account.uri)
+  rescue Mastodon::UnexpectedResponseError => e
+    response = e.response
+
+    if response_error_unsalvageable?(response)
+      # Give up
+    else
+      raise e
+    end
+  end
+end