no need to care promise orders

This commit is contained in:
Namekuji 2023-04-13 10:49:17 -04:00
parent 91fcad0c85
commit 0474efc008
2 changed files with 18 additions and 14 deletions

View File

@ -118,14 +118,12 @@ export class AccountMoveService {
@bindThis
public async move(src: User, dst: User): Promise<void> {
// 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<void> {
// 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 },

View File

@ -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 */
}