about summary refs log tree commit diff
path: root/app/workers/activitypub/migrated_follow_delivery_worker.rb
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2023-03-15 08:58:12 +0100
committerGitHub <noreply@github.com>2023-03-15 08:58:12 +0100
commit6a0ed45aa3f11f0343a7be556b36b4d075ba08df (patch)
tree0bbd3318c61cf062f17386f4da166864c9db8138 /app/workers/activitypub/migrated_follow_delivery_worker.rb
parentbb4e211c86270de6de8a78da96295208ee77dce1 (diff)
parent7f96391eaef601ea34672551bb06915acec7e492 (diff)
Merge pull request #2122 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/workers/activitypub/migrated_follow_delivery_worker.rb')
-rw-r--r--app/workers/activitypub/migrated_follow_delivery_worker.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/app/workers/activitypub/migrated_follow_delivery_worker.rb b/app/workers/activitypub/migrated_follow_delivery_worker.rb
new file mode 100644
index 000000000..daf30e0ae
--- /dev/null
+++ b/app/workers/activitypub/migrated_follow_delivery_worker.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class ActivityPub::MigratedFollowDeliveryWorker < ActivityPub::DeliveryWorker
+  def perform(json, source_account_id, inbox_url, old_target_account_id, options = {})
+    super(json, source_account_id, inbox_url, options)
+    unfollow_old_account!(old_target_account_id)
+  end
+
+  private
+
+  def unfollow_old_account!(old_target_account_id)
+    old_target_account = Account.find(old_target_account_id)
+    UnfollowService.new.call(@source_account, old_target_account, skip_unmerge: true)
+  rescue
+    true
+  end
+end