From 453ae4b32efec06b4040c7f7e578b3f86257ac7d Mon Sep 17 00:00:00 2001 From: Emily Love Watson Date: Wed, 8 Oct 2025 14:15:34 -0500 Subject: [PATCH 01/10] MVP migration --- .../ProfileMigrationController.php | 8 ++++-- .../MoveMigrateFollowersPipeline.php | 17 ++++++------ .../MovePipeline/MoveSendFollowPipeline.php | 3 ++- ...leMigrationDeliverMoveActivityPipeline.php | 5 ++-- .../ProfileMigrationMoveFollowersPipeline.php | 27 +++++++++++++------ app/Transformer/ActivityPub/Verb/Move.php | 8 +++--- 6 files changed, 43 insertions(+), 25 deletions(-) diff --git a/app/Http/Controllers/ProfileMigrationController.php b/app/Http/Controllers/ProfileMigrationController.php index 9ac90531c..48f5b4a2a 100644 --- a/app/Http/Controllers/ProfileMigrationController.php +++ b/app/Http/Controllers/ProfileMigrationController.php @@ -5,11 +5,13 @@ namespace App\Http\Controllers; use App\Http\Requests\ProfileMigrationStoreRequest; use App\Jobs\ProfilePipeline\ProfileMigrationDeliverMoveActivityPipeline; use App\Jobs\ProfilePipeline\ProfileMigrationMoveFollowersPipeline; +use App\Jobs\MovePipeline\MoveMigrateFollowersPipeline; use App\Models\ProfileAlias; use App\Models\ProfileMigration; use App\Services\AccountService; use App\Services\WebfingerService; use App\Util\ActivityPub\Helpers; +use Cache; use Illuminate\Http\Request; use Illuminate\Support\Facades\Bus; @@ -61,15 +63,17 @@ class ProfileMigrationController extends Controller 'indexable' => false, ]); AccountService::del($user->profile_id); + Cache::forget('pfc:cached-user:wt:'.strtolower($user->profile->username)); + Cache::forget('pfc:cached-user:wot:'.strtolower($user->profile->username)); Bus::batch([ [ new ProfileMigrationDeliverMoveActivityPipeline($migration, $user->profile, $newAccount), ], [ - new ProfileMigrationMoveFollowersPipeline($user->profile_id, $newAccount->id), + new ProfileMigrationMoveFollowersPipeline($user->profile_id, $newAccount->id, $request->safe()->acct, $newAccount->permalink()), ] - ])->onQueue('follow')->dispatch(); + ])->onQueue('move')->dispatch(); return redirect()->back()->with(['status' => 'Succesfully migrated account!']); } diff --git a/app/Jobs/MovePipeline/MoveMigrateFollowersPipeline.php b/app/Jobs/MovePipeline/MoveMigrateFollowersPipeline.php index 1cde3818e..021cae1e0 100644 --- a/app/Jobs/MovePipeline/MoveMigrateFollowersPipeline.php +++ b/app/Jobs/MovePipeline/MoveMigrateFollowersPipeline.php @@ -118,14 +118,15 @@ class MoveMigrateFollowersPipeline implements ShouldQueue if (! $follower->private_key || ! $follower->username || ! $follower->user_id || $follower->status === 'delete') { continue; } - - Follower::updateOrCreate([ - 'profile_id' => $follower->id, - 'following_id' => $targetPid, - ]); - - MoveSendFollowPipeline::dispatch($follower, $targetInbox, $targetPid, $target)->onQueue('follow'); + if ($targetInbox) { + MoveSendFollowPipeline::dispatch($follower, $targetInbox, $targetPid, $target)->onQueue('follow'); + } else { + Follower::updateOrCreate([ + 'profile_id' => $follower->id, + 'following_id' => $targetPid, + ]); + } } - }, 'id'); + }, 'profiles.id'); } } diff --git a/app/Jobs/MovePipeline/MoveSendFollowPipeline.php b/app/Jobs/MovePipeline/MoveSendFollowPipeline.php index 6d1cef5e1..bdf9def62 100644 --- a/app/Jobs/MovePipeline/MoveSendFollowPipeline.php +++ b/app/Jobs/MovePipeline/MoveSendFollowPipeline.php @@ -9,6 +9,7 @@ use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Queue\Queueable; use Illuminate\Queue\Middleware\ThrottlesExceptions; use Illuminate\Queue\Middleware\WithoutOverlapping; +use Illuminate\Support\Facades\Log; class MoveSendFollowPipeline implements ShouldQueue { @@ -107,7 +108,7 @@ class MoveSendFollowPipeline implements ShouldQueue ], ]); } catch (ClientException $e) { - + Log::error($e); } } } diff --git a/app/Jobs/ProfilePipeline/ProfileMigrationDeliverMoveActivityPipeline.php b/app/Jobs/ProfilePipeline/ProfileMigrationDeliverMoveActivityPipeline.php index 5fa27c33d..fd5882cab 100644 --- a/app/Jobs/ProfilePipeline/ProfileMigrationDeliverMoveActivityPipeline.php +++ b/app/Jobs/ProfilePipeline/ProfileMigrationDeliverMoveActivityPipeline.php @@ -14,6 +14,7 @@ use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\Middleware\WithoutOverlapping; use Illuminate\Queue\SerializesModels; +use Illuminate\Support\Facades\Log; use League\Fractal; use League\Fractal\Serializer\ArraySerializer; @@ -128,8 +129,8 @@ class ProfileMigrationDeliverMoveActivityPipeline implements ShouldBeUniqueUntil $pool = new Pool($client, $requests($audience), [ 'concurrency' => config('federation.activitypub.delivery.concurrency'), 'fulfilled' => function ($response, $index) { - }, - 'rejected' => function ($reason, $index) { + }, 'rejected' => function ($reason, $index) { + Log::error($reason); }, ]); diff --git a/app/Jobs/ProfilePipeline/ProfileMigrationMoveFollowersPipeline.php b/app/Jobs/ProfilePipeline/ProfileMigrationMoveFollowersPipeline.php index c3d825ec9..4b64a3039 100644 --- a/app/Jobs/ProfilePipeline/ProfileMigrationMoveFollowersPipeline.php +++ b/app/Jobs/ProfilePipeline/ProfileMigrationMoveFollowersPipeline.php @@ -3,6 +3,7 @@ namespace App\Jobs\ProfilePipeline; use App\Follower; +use App\Http\Controllers\FollowerController; use App\Profile; use App\Services\AccountService; use Illuminate\Bus\Batchable; @@ -13,6 +14,7 @@ use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\Middleware\WithoutOverlapping; use Illuminate\Queue\SerializesModels; +use Illuminate\Support\Facades\Log; class ProfileMigrationMoveFollowersPipeline implements ShouldBeUniqueUntilProcessing, ShouldQueue { @@ -77,16 +79,25 @@ class ProfileMigrationMoveFollowersPipeline implements ShouldBeUniqueUntilProces if (! $og || ! $ne || $og == $ne) { return; } - $ne->followers_count = $og->followers_count; - $ne->save(); - $og->followers_count = 0; - $og->save(); - foreach (Follower::whereFollowingId($this->oldPid)->lazyById(200, 'id') as $follower) { + + $targetInbox = $ne['sharedInbox'] ?? $ne['inbox_url']; + foreach (Follower::whereFollowingId($this->oldPid)->where('local_profile', true)->lazyById(200, 'id') as $follower) { try { - $follower->following_id = $this->newPid; - $follower->save(); + if ($targetInbox) { + $followerProfile = Profile::find($follower->profile_id); + Follower::updateOrCreate([ + 'profile_id' => $follower->profile_id, + 'following_id' => $this->newPid, + ]); + (new FollowerController)->sendFollow($followerProfile, $ne); + } else { + Follower::updateOrCreate([ + 'profile_id' => $follower->profile_id, + 'following_id' => $this->newPid, + ]); + } } catch (Exception $e) { - $follower->delete(); + Log::error($e); } } AccountService::del($this->oldPid); diff --git a/app/Transformer/ActivityPub/Verb/Move.php b/app/Transformer/ActivityPub/Verb/Move.php index 2460914be..aedb32e59 100644 --- a/app/Transformer/ActivityPub/Verb/Move.php +++ b/app/Transformer/ActivityPub/Verb/Move.php @@ -9,9 +9,9 @@ class Move extends Fractal\TransformerAbstract { public function transform(ProfileMigration $migration) { - $objUrl = $migration->target->permalink(); - $id = $migration->target->permalink('#moves/'.$migration->id); - $to = $migration->target->permalink('/followers'); + $objUrl = $migration->profile->permalink(); + $id = $migration->profile->permalink('#moves/'.$migration->id); + $to = $migration->profile->permalink('/followers'); return [ '@context' => 'https://www.w3.org/ns/activitystreams', @@ -19,7 +19,7 @@ class Move extends Fractal\TransformerAbstract 'actor' => $objUrl, 'type' => 'Move', 'object' => $objUrl, - 'target' => $migration->profile->permalink(), + 'target' => $migration->target->permalink(), 'to' => $to, ]; } From a07f3595d8e10afdb858423ac410e5416d9a04f8 Mon Sep 17 00:00:00 2001 From: Emily Love Watson Date: Wed, 8 Oct 2025 17:48:41 -0500 Subject: [PATCH 02/10] More cleanup --- .../MoveMigrateFollowersPipeline.php | 6 +++++- .../ProfileMigrationMoveFollowersPipeline.php | 17 ++++++----------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/app/Jobs/MovePipeline/MoveMigrateFollowersPipeline.php b/app/Jobs/MovePipeline/MoveMigrateFollowersPipeline.php index 021cae1e0..1f4ae59cb 100644 --- a/app/Jobs/MovePipeline/MoveMigrateFollowersPipeline.php +++ b/app/Jobs/MovePipeline/MoveMigrateFollowersPipeline.php @@ -3,6 +3,8 @@ namespace App\Jobs\MovePipeline; use App\Follower; +use App\Http\Controllers\FollowerController; +use App\Profile; use App\Util\ActivityPub\Helpers; use DateTime; use DB; @@ -118,8 +120,10 @@ class MoveMigrateFollowersPipeline implements ShouldQueue if (! $follower->private_key || ! $follower->username || ! $follower->user_id || $follower->status === 'delete') { continue; } + if ($targetInbox) { - MoveSendFollowPipeline::dispatch($follower, $targetInbox, $targetPid, $target)->onQueue('follow'); + $followerProfile = Profile::find($follower->id); + (new FollowerController)->sendFollow($followerProfile, $targetAccount); } else { Follower::updateOrCreate([ 'profile_id' => $follower->id, diff --git a/app/Jobs/ProfilePipeline/ProfileMigrationMoveFollowersPipeline.php b/app/Jobs/ProfilePipeline/ProfileMigrationMoveFollowersPipeline.php index 4b64a3039..137dc61b8 100644 --- a/app/Jobs/ProfilePipeline/ProfileMigrationMoveFollowersPipeline.php +++ b/app/Jobs/ProfilePipeline/ProfileMigrationMoveFollowersPipeline.php @@ -81,21 +81,16 @@ class ProfileMigrationMoveFollowersPipeline implements ShouldBeUniqueUntilProces } $targetInbox = $ne['sharedInbox'] ?? $ne['inbox_url']; - foreach (Follower::whereFollowingId($this->oldPid)->where('local_profile', true)->lazyById(200, 'id') as $follower) { + foreach (Follower::whereFollowingId($this->oldPid)->lazyById(200, 'id') as $follower) { try { - if ($targetInbox) { + if ($targetInbox && $follower->local_profile) { $followerProfile = Profile::find($follower->profile_id); - Follower::updateOrCreate([ - 'profile_id' => $follower->profile_id, - 'following_id' => $this->newPid, - ]); (new FollowerController)->sendFollow($followerProfile, $ne); - } else { - Follower::updateOrCreate([ - 'profile_id' => $follower->profile_id, - 'following_id' => $this->newPid, - ]); } + Follower::updateOrCreate([ + 'profile_id' => $follower->profile_id, + 'following_id' => $this->newPid, + ]); } catch (Exception $e) { Log::error($e); } From 451d59cb7c7037a16df297cf157c28685a246e77 Mon Sep 17 00:00:00 2001 From: Emily Love Watson Date: Wed, 8 Oct 2025 19:58:01 -0500 Subject: [PATCH 03/10] fixies --- app/Jobs/MovePipeline/MoveMigrateFollowersPipeline.php | 4 ++-- app/Jobs/MovePipeline/UnfollowLegacyAccountMovePipeline.php | 2 +- .../ProfileMigrationMoveFollowersPipeline.php | 6 ++---- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/Jobs/MovePipeline/MoveMigrateFollowersPipeline.php b/app/Jobs/MovePipeline/MoveMigrateFollowersPipeline.php index 1f4ae59cb..2dca9c03c 100644 --- a/app/Jobs/MovePipeline/MoveMigrateFollowersPipeline.php +++ b/app/Jobs/MovePipeline/MoveMigrateFollowersPipeline.php @@ -115,7 +115,7 @@ class MoveMigrateFollowersPipeline implements ShouldQueue ->whereNotNull('profiles.user_id') ->whereNull('profiles.deleted_at') ->select('profiles.id', 'profiles.user_id', 'profiles.username', 'profiles.private_key', 'profiles.status') - ->chunkById(100, function ($followers) use ($targetInbox, $targetPid, $target) { + ->chunkById(100, function ($followers) use ($targetInbox, $targetPid, $targetAccount) { foreach ($followers as $follower) { if (! $follower->private_key || ! $follower->username || ! $follower->user_id || $follower->status === 'delete') { continue; @@ -131,6 +131,6 @@ class MoveMigrateFollowersPipeline implements ShouldQueue ]); } } - }, 'profiles.id'); + }, 'profiles.id', 'id'); } } diff --git a/app/Jobs/MovePipeline/UnfollowLegacyAccountMovePipeline.php b/app/Jobs/MovePipeline/UnfollowLegacyAccountMovePipeline.php index 47ed2aeb6..6f30b797e 100644 --- a/app/Jobs/MovePipeline/UnfollowLegacyAccountMovePipeline.php +++ b/app/Jobs/MovePipeline/UnfollowLegacyAccountMovePipeline.php @@ -106,6 +106,6 @@ class UnfollowLegacyAccountMovePipeline implements ShouldQueue MoveSendUndoFollowPipeline::dispatch($follower, $targetInbox, $targetPid, $actor)->onQueue('move'); } - }, 'id'); + }, 'profiles.id', 'id'); } } diff --git a/app/Jobs/ProfilePipeline/ProfileMigrationMoveFollowersPipeline.php b/app/Jobs/ProfilePipeline/ProfileMigrationMoveFollowersPipeline.php index 137dc61b8..9b954263d 100644 --- a/app/Jobs/ProfilePipeline/ProfileMigrationMoveFollowersPipeline.php +++ b/app/Jobs/ProfilePipeline/ProfileMigrationMoveFollowersPipeline.php @@ -87,10 +87,8 @@ class ProfileMigrationMoveFollowersPipeline implements ShouldBeUniqueUntilProces $followerProfile = Profile::find($follower->profile_id); (new FollowerController)->sendFollow($followerProfile, $ne); } - Follower::updateOrCreate([ - 'profile_id' => $follower->profile_id, - 'following_id' => $this->newPid, - ]); + $follower->following_id = $this->newPid; + $follower->save(); } catch (Exception $e) { Log::error($e); } From 74bf7e45c85dcc915249a2f61840680e96cb4acc Mon Sep 17 00:00:00 2001 From: Emily Love Watson Date: Wed, 8 Oct 2025 20:18:23 -0500 Subject: [PATCH 04/10] Restore follower count logic --- .../ProfilePipeline/ProfileMigrationMoveFollowersPipeline.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/Jobs/ProfilePipeline/ProfileMigrationMoveFollowersPipeline.php b/app/Jobs/ProfilePipeline/ProfileMigrationMoveFollowersPipeline.php index 9b954263d..a1575d3aa 100644 --- a/app/Jobs/ProfilePipeline/ProfileMigrationMoveFollowersPipeline.php +++ b/app/Jobs/ProfilePipeline/ProfileMigrationMoveFollowersPipeline.php @@ -79,6 +79,10 @@ class ProfileMigrationMoveFollowersPipeline implements ShouldBeUniqueUntilProces if (! $og || ! $ne || $og == $ne) { return; } + $ne->followers_count = $og->followers_count; + $ne->save(); + $og->followers_count = 0; + $og->save(); $targetInbox = $ne['sharedInbox'] ?? $ne['inbox_url']; foreach (Follower::whereFollowingId($this->oldPid)->lazyById(200, 'id') as $follower) { From 871efff1a8e3bbc54d3f8087dea3560085bc4f9f Mon Sep 17 00:00:00 2001 From: Emily Love Watson Date: Wed, 8 Oct 2025 20:19:40 -0500 Subject: [PATCH 05/10] Remove unused params --- app/Http/Controllers/ProfileMigrationController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/ProfileMigrationController.php b/app/Http/Controllers/ProfileMigrationController.php index 48f5b4a2a..537e2dc36 100644 --- a/app/Http/Controllers/ProfileMigrationController.php +++ b/app/Http/Controllers/ProfileMigrationController.php @@ -71,7 +71,7 @@ class ProfileMigrationController extends Controller new ProfileMigrationDeliverMoveActivityPipeline($migration, $user->profile, $newAccount), ], [ - new ProfileMigrationMoveFollowersPipeline($user->profile_id, $newAccount->id, $request->safe()->acct, $newAccount->permalink()), + new ProfileMigrationMoveFollowersPipeline($user->profile_id, $newAccount->id), ] ])->onQueue('move')->dispatch(); From 2272c3ec01527b759030537f390f4d8fc0c99cb1 Mon Sep 17 00:00:00 2001 From: Emily Love Watson Date: Wed, 8 Oct 2025 20:21:49 -0500 Subject: [PATCH 06/10] Cleanup --- .../MovePipeline/MoveSendFollowPipeline.php | 114 ------------------ 1 file changed, 114 deletions(-) delete mode 100644 app/Jobs/MovePipeline/MoveSendFollowPipeline.php diff --git a/app/Jobs/MovePipeline/MoveSendFollowPipeline.php b/app/Jobs/MovePipeline/MoveSendFollowPipeline.php deleted file mode 100644 index bdf9def62..000000000 --- a/app/Jobs/MovePipeline/MoveSendFollowPipeline.php +++ /dev/null @@ -1,114 +0,0 @@ - - */ - public function middleware(): array - { - return [ - new WithoutOverlapping('move-send-follow:'.$this->follower->id.':target:'.$this->target), - (new ThrottlesExceptions(2, 5 * 60))->backoff(5), - ]; - } - - /** - * Create a new job instance. - */ - public function __construct($follower, $targetInbox, $targetPid, $target) - { - $this->follower = $follower; - $this->targetInbox = $targetInbox; - $this->targetPid = $targetPid; - $this->target = $target; - } - - /** - * Execute the job. - */ - public function handle(): void - { - $follower = $this->follower; - $targetPid = $this->targetPid; - $targetInbox = $this->targetInbox; - $target = $this->target; - - if (! $follower->username || ! $follower->private_key) { - return; - } - - $permalink = 'https://'.config('pixelfed.domain.app').'/users/'.$follower->username; - $version = config('pixelfed.version'); - $appUrl = config('app.url'); - $userAgent = "(Pixelfed/{$version}; +{$appUrl})"; - $addlHeaders = [ - 'Content-Type' => 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"', - 'User-Agent' => $userAgent, - ]; - - $activity = [ - '@context' => 'https://www.w3.org/ns/activitystreams', - 'type' => 'Follow', - 'actor' => $permalink, - 'object' => $target, - ]; - - $keyId = $permalink.'#main-key'; - $payload = json_encode($activity); - $headers = HttpSignature::signRaw($follower->private_key, $keyId, $targetInbox, $activity, $addlHeaders); - - $client = new Client([ - 'timeout' => config('federation.activitypub.delivery.timeout'), - ]); - - try { - $client->post($targetInbox, [ - 'curl' => [ - CURLOPT_HTTPHEADER => $headers, - CURLOPT_POSTFIELDS => $payload, - CURLOPT_HEADER => true, - ], - ]); - } catch (ClientException $e) { - Log::error($e); - } - } -} From 2052d618e83d24726808de947ff36e2c8fb69323 Mon Sep 17 00:00:00 2001 From: Emily Love Watson Date: Wed, 8 Oct 2025 20:25:35 -0500 Subject: [PATCH 07/10] Cleanup legacy follower count --- app/Jobs/MovePipeline/CleanupLegacyAccountMovePipeline.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Jobs/MovePipeline/CleanupLegacyAccountMovePipeline.php b/app/Jobs/MovePipeline/CleanupLegacyAccountMovePipeline.php index d26ad5624..4ba27308f 100644 --- a/app/Jobs/MovePipeline/CleanupLegacyAccountMovePipeline.php +++ b/app/Jobs/MovePipeline/CleanupLegacyAccountMovePipeline.php @@ -95,6 +95,7 @@ class CleanupLegacyAccountMovePipeline implements ShouldQueue if ($oldProfile) { $oldProfile->moved_to_profile_id = $targetAccount['id']; + $oldProfile->followers_count = 0; $oldProfile->save(); AccountService::del($oldProfile->id); AccountService::del($targetAccount['id']); From 49b0a7358e6b39e7f234f55f5338d3d5975cce39 Mon Sep 17 00:00:00 2001 From: Emily Love Watson Date: Wed, 8 Oct 2025 21:04:19 -0500 Subject: [PATCH 08/10] Update follower records --- app/Jobs/MovePipeline/MoveMigrateFollowersPipeline.php | 9 ++++----- .../ProfileMigrationMoveFollowersPipeline.php | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/Jobs/MovePipeline/MoveMigrateFollowersPipeline.php b/app/Jobs/MovePipeline/MoveMigrateFollowersPipeline.php index 2dca9c03c..0fb9ed0ff 100644 --- a/app/Jobs/MovePipeline/MoveMigrateFollowersPipeline.php +++ b/app/Jobs/MovePipeline/MoveMigrateFollowersPipeline.php @@ -121,14 +121,13 @@ class MoveMigrateFollowersPipeline implements ShouldQueue continue; } + Follower::updateOrCreate([ + 'profile_id' => $follower->id, + 'following_id' => $targetPid, + ]); if ($targetInbox) { $followerProfile = Profile::find($follower->id); (new FollowerController)->sendFollow($followerProfile, $targetAccount); - } else { - Follower::updateOrCreate([ - 'profile_id' => $follower->id, - 'following_id' => $targetPid, - ]); } } }, 'profiles.id', 'id'); diff --git a/app/Jobs/ProfilePipeline/ProfileMigrationMoveFollowersPipeline.php b/app/Jobs/ProfilePipeline/ProfileMigrationMoveFollowersPipeline.php index a1575d3aa..4f416801d 100644 --- a/app/Jobs/ProfilePipeline/ProfileMigrationMoveFollowersPipeline.php +++ b/app/Jobs/ProfilePipeline/ProfileMigrationMoveFollowersPipeline.php @@ -87,12 +87,12 @@ class ProfileMigrationMoveFollowersPipeline implements ShouldBeUniqueUntilProces $targetInbox = $ne['sharedInbox'] ?? $ne['inbox_url']; foreach (Follower::whereFollowingId($this->oldPid)->lazyById(200, 'id') as $follower) { try { + $follower->following_id = $this->newPid; + $follower->save(); if ($targetInbox && $follower->local_profile) { $followerProfile = Profile::find($follower->profile_id); (new FollowerController)->sendFollow($followerProfile, $ne); } - $follower->following_id = $this->newPid; - $follower->save(); } catch (Exception $e) { Log::error($e); } From 7709d5da29f103e92038554f9c672147b3e269b1 Mon Sep 17 00:00:00 2001 From: Emily Love Watson Date: Thu, 9 Oct 2025 15:25:24 -0500 Subject: [PATCH 09/10] Cleanup --- app/Http/Controllers/ProfileMigrationController.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Http/Controllers/ProfileMigrationController.php b/app/Http/Controllers/ProfileMigrationController.php index 537e2dc36..0ed134cf0 100644 --- a/app/Http/Controllers/ProfileMigrationController.php +++ b/app/Http/Controllers/ProfileMigrationController.php @@ -5,7 +5,6 @@ namespace App\Http\Controllers; use App\Http\Requests\ProfileMigrationStoreRequest; use App\Jobs\ProfilePipeline\ProfileMigrationDeliverMoveActivityPipeline; use App\Jobs\ProfilePipeline\ProfileMigrationMoveFollowersPipeline; -use App\Jobs\MovePipeline\MoveMigrateFollowersPipeline; use App\Models\ProfileAlias; use App\Models\ProfileMigration; use App\Services\AccountService; From e645008ad505d8f229c7abb7b49e3fca1638c8f0 Mon Sep 17 00:00:00 2001 From: Emily Love Watson Date: Thu, 9 Oct 2025 15:41:57 -0500 Subject: [PATCH 10/10] More precise --- app/Jobs/MovePipeline/MoveMigrateFollowersPipeline.php | 8 ++++++-- .../ProfileMigrationMoveFollowersPipeline.php | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/Jobs/MovePipeline/MoveMigrateFollowersPipeline.php b/app/Jobs/MovePipeline/MoveMigrateFollowersPipeline.php index 0fb9ed0ff..7780f7685 100644 --- a/app/Jobs/MovePipeline/MoveMigrateFollowersPipeline.php +++ b/app/Jobs/MovePipeline/MoveMigrateFollowersPipeline.php @@ -114,7 +114,7 @@ class MoveMigrateFollowersPipeline implements ShouldQueue ->where('followers.following_id', $actorAccount['id']) ->whereNotNull('profiles.user_id') ->whereNull('profiles.deleted_at') - ->select('profiles.id', 'profiles.user_id', 'profiles.username', 'profiles.private_key', 'profiles.status') + ->select('profiles.id', 'profiles.user_id', 'profiles.username', 'profiles.private_key', 'profiles.status', 'followers.local_profile') ->chunkById(100, function ($followers) use ($targetInbox, $targetPid, $targetAccount) { foreach ($followers as $follower) { if (! $follower->private_key || ! $follower->username || ! $follower->user_id || $follower->status === 'delete') { @@ -125,7 +125,11 @@ class MoveMigrateFollowersPipeline implements ShouldQueue 'profile_id' => $follower->id, 'following_id' => $targetPid, ]); - if ($targetInbox) { + + // If the remote user has migrated to a different instance, + // send a follow request for each local follower to the new + // instance + if ($targetInbox && $follower->local_profile) { $followerProfile = Profile::find($follower->id); (new FollowerController)->sendFollow($followerProfile, $targetAccount); } diff --git a/app/Jobs/ProfilePipeline/ProfileMigrationMoveFollowersPipeline.php b/app/Jobs/ProfilePipeline/ProfileMigrationMoveFollowersPipeline.php index 4f416801d..b479cf871 100644 --- a/app/Jobs/ProfilePipeline/ProfileMigrationMoveFollowersPipeline.php +++ b/app/Jobs/ProfilePipeline/ProfileMigrationMoveFollowersPipeline.php @@ -89,6 +89,9 @@ class ProfileMigrationMoveFollowersPipeline implements ShouldBeUniqueUntilProces try { $follower->following_id = $this->newPid; $follower->save(); + + // If a local user has migrated to a different instance, send a + // follow request for each local follower to the new instance if ($targetInbox && $follower->local_profile) { $followerProfile = Profile::find($follower->profile_id); (new FollowerController)->sendFollow($followerProfile, $ne);