From 0474efc008d739349112aae72a6d8d41b13e64b8 Mon Sep 17 00:00:00 2001 From: Namekuji Date: Thu, 13 Apr 2023 10:49:17 -0400 Subject: [PATCH] no need to care promise orders --- .../backend/src/core/AccountMoveService.ts | 24 ++++++++++--------- .../activitypub/models/ApPersonService.ts | 8 ++++--- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/packages/backend/src/core/AccountMoveService.ts b/packages/backend/src/core/AccountMoveService.ts index 5f63d30089..75b15e0522 100644 --- a/packages/backend/src/core/AccountMoveService.ts +++ b/packages/backend/src/core/AccountMoveService.ts @@ -118,14 +118,12 @@ export class AccountMoveService { @bindThis public async move(src: User, dst: User): Promise { - // Copy blockings: - await this.copyBlocking(src, dst); - - // Copy mutings: - await this.copyMutings(src, dst); - - // Update lists: - await this.updateLists(src, dst); + // Copy blockings and mutings, and update lists + await Promise.all([ + this.copyBlocking(src, dst), + this.copyMutings(src, dst), + this.updateLists(src, dst), + ]); // follow the new account and unfollow the old one const followings = await this.followingsRepository.find({ @@ -195,9 +193,13 @@ export class AccountMoveService { @bindThis public async updateLists(src: ThinUser, dst: User): Promise { - // Return if there is no list to be updated - const numOfLists = await this.userListJoiningsRepository.countBy({ userId: src.id }); - if (numOfLists === 0) return; + // Return if there is no list to be updated. + const exists = await this.userListJoiningsRepository.exist({ + where: { + userId: src.id, + }, + }); + if (!exists) return; await this.userListJoiningsRepository.update( { userId: src.id }, diff --git a/packages/backend/src/core/activitypub/models/ApPersonService.ts b/packages/backend/src/core/activitypub/models/ApPersonService.ts index 2a5d380356..819e8b9bf5 100644 --- a/packages/backend/src/core/activitypub/models/ApPersonService.ts +++ b/packages/backend/src/core/activitypub/models/ApPersonService.ts @@ -533,9 +533,11 @@ export class ApPersonService implements OnModuleInit { const newAccount = await this.resolvePerson(updates.movedToUri); // Aggressively block and/or mute the new account: // This does NOT check alsoKnownAs, assuming that other implmenetations properly check alsoKnownAs when firing account migration - await this.accountMoveService.copyBlocking(exist, newAccount); - await this.accountMoveService.copyMutings(exist, newAccount); - await this.accountMoveService.updateLists(exist, newAccount); + await Promise.all([ + this.accountMoveService.copyBlocking(exist, newAccount), + this.accountMoveService.copyMutings(exist, newAccount), + this.accountMoveService.updateLists(exist, newAccount), + ]); } catch { /* skip if any error happens */ }