about summary refs log tree commit diff
path: root/app/workers
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2020-12-19 00:55:12 +0100
committerClaire <claire.github-309c@sitedethib.com>2020-12-19 00:55:12 +0100
commitf9d000ebaec7732d5fcd46aa6685108a2619966b (patch)
tree9593841cf520b117ca4c3d5b68b19e9124c852da /app/workers
parent92cfcf168cae094ece281b3cb6d0f5b1539a8c25 (diff)
parentc6598b17d9212c2d48395da73fa9529025d704cc (diff)
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts:
- `app/services/resolve_url_service.rb`:
  The private toot search by URL hack has been revamped upstream.
  Took upstream's version.
Diffstat (limited to 'app/workers')
-rw-r--r--app/workers/account_merging_worker.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/app/workers/account_merging_worker.rb b/app/workers/account_merging_worker.rb
new file mode 100644
index 000000000..8c234e7ac
--- /dev/null
+++ b/app/workers/account_merging_worker.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AccountMergingWorker
+  include Sidekiq::Worker
+
+  sidekiq_options queue: 'pull'
+
+  def perform(account_id)
+    account = Account.find(account_id)
+
+    return true if account.nil? || account.local?
+
+    Account.where(uri: account.uri).where.not(id: account.id).find_each do |duplicate|
+      account.merge_with!(duplicate)
+      duplicate.destroy
+    end
+  end
+end