From 050f1669c6fc02d7a917261d16d9264512955bc6 Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 3 Mar 2023 21:13:55 +0100 Subject: Fix original account being unfollowed on migration before the follow request could be sent (#21957) --- .../activitypub/migrated_follow_delivery_worker.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 app/workers/activitypub/migrated_follow_delivery_worker.rb (limited to 'app/workers/activitypub/migrated_follow_delivery_worker.rb') 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..17a9e515e --- /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 StandardError + true + end +end -- cgit From b00f945d92b6fff58c8a8ed702a9511ddb56a3da Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Fri, 3 Mar 2023 16:49:16 -0500 Subject: Remove implied StandardError rescue (#23942) --- app/workers/activitypub/migrated_follow_delivery_worker.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/workers/activitypub/migrated_follow_delivery_worker.rb') diff --git a/app/workers/activitypub/migrated_follow_delivery_worker.rb b/app/workers/activitypub/migrated_follow_delivery_worker.rb index 17a9e515e..daf30e0ae 100644 --- a/app/workers/activitypub/migrated_follow_delivery_worker.rb +++ b/app/workers/activitypub/migrated_follow_delivery_worker.rb @@ -11,7 +11,7 @@ class ActivityPub::MigratedFollowDeliveryWorker < ActivityPub::DeliveryWorker 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 StandardError + rescue true end end -- cgit