From 958ce7224943be1b5db9c577bdadd538ac8cbc99 Mon Sep 17 00:00:00 2001 From: Hazelnoot Date: Sun, 14 Sep 2025 10:00:46 -0400 Subject: [PATCH] when migrating accounts, don't block the target if already following --- packages/backend/src/core/AccountMoveService.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/backend/src/core/AccountMoveService.ts b/packages/backend/src/core/AccountMoveService.ts index 74236157ac..360233e6d3 100644 --- a/packages/backend/src/core/AccountMoveService.ts +++ b/packages/backend/src/core/AccountMoveService.ts @@ -183,14 +183,17 @@ export class AccountMoveService { public async copyBlocking(src: ThinUser, dst: ThinUser): Promise { // Followers shouldn't overlap with blockers, but the destination account, different from the blockee (i.e., old account), may have followed the local user before moving. // So block the destination account here. - const srcBlockings = await this.blockingsRepository.findBy({ blockeeId: src.id }); - const dstBlockings = await this.blockingsRepository.findBy({ blockeeId: dst.id }); - const blockerIds = dstBlockings.map(blocking => blocking.blockerId); + const [srcBlockers, dstBlockers, dstFollowers] = await Promise.all([ + this.cacheService.userBlockedCache.fetch(src.id), + this.cacheService.userBlockedCache.fetch(dst.id), + this.cacheService.userFollowersCache.fetch(dst.id), + ]); // reblock the destination account const blockJobs: RelationshipJobData[] = []; - for (const blocking of srcBlockings) { - if (blockerIds.includes(blocking.blockerId)) continue; // skip if already blocked - blockJobs.push({ from: { id: blocking.blockerId }, to: { id: dst.id } }); + for (const blockerId of srcBlockers) { + if (dstBlockers.has(blockerId)) continue; // skip if already blocked + if (dstFollowers.has(blockerId)) continue; // skip if already following + blockJobs.push({ from: { id: blockerId }, to: { id: dst.id } }); } // no need to unblock the old account because it may be still functional await this.queueService.createBlockJob(blockJobs);