about summary refs log tree commit diff
path: root/app/workers/reset_account_worker.rb
diff options
context:
space:
mode:
authorFire Demon <firedemon@creature.cafe>2020-09-01 19:39:52 -0500
committerStarfall <us@starfall.systems>2020-09-01 23:21:55 -0500
commita43c1d3f56c128c992f34b8e2b968de14e02ac48 (patch)
tree27f8ebe4134b00ed0904dd5434cd82a710244e1e /app/workers/reset_account_worker.rb
parente132da51a62f1a30f3998496ed2dee0b6762a51a (diff)
from monsterfork: [Privacy] Purge and re-download remote accounts if their actor key suddenly changes
Diffstat (limited to 'app/workers/reset_account_worker.rb')
-rw-r--r--app/workers/reset_account_worker.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/app/workers/reset_account_worker.rb b/app/workers/reset_account_worker.rb
new file mode 100644
index 000000000..f63d8682a
--- /dev/null
+++ b/app/workers/reset_account_worker.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class ResetAccountWorker
+  include Sidekiq::Worker
+
+  def perform(account_id)
+    account = Account.find(account_id)
+    return if account.local?
+
+    account_uri = account.uri
+    SuspendAccountService.new.call(account)
+    ResolveAccountService.new.call(account_uri)
+  rescue ActiveRecord::RecordNotFound
+    true
+  end
+end