diff --git a/packages/backend/src/core/UserFollowingService.ts b/packages/backend/src/core/UserFollowingService.ts index df85ec8529..d979974996 100644 --- a/packages/backend/src/core/UserFollowingService.ts +++ b/packages/backend/src/core/UserFollowingService.ts @@ -86,7 +86,7 @@ export class UserFollowingService implements OnModuleInit { @bindThis public async follow(_follower: { id: User['id'] }, _followee: { id: User['id'] }, requestId?: string, silent = false): Promise { - const [follower, followee] = await Promise.all([ + let [follower, followee] = await Promise.all([ this.usersRepository.findOneByOrFail({ id: _follower.id }), this.usersRepository.findOneByOrFail({ id: _followee.id }), ]); @@ -140,21 +140,27 @@ export class UserFollowingService implements OnModuleInit { } // Automatically accept if the follower is an account who has moved and the locked followee had accepted the old account. - if (followee.isLocked && !autoAccept && follower.alsoKnownAs) { - for (const oldUri of follower.alsoKnownAs) { - try { - await this.apPersonService.updatePerson(oldUri); - const oldAccount = await this.apPersonService.resolvePerson(oldUri); - const newUri = this.userEntityService.isRemoteUser(follower) ? follower.uri : `${this.config.url}/users/${follower.id}`; + if (followee.isLocked && !autoAccept) { + if (this.userEntityService.isRemoteUser(follower)) { + await this.apPersonService.updatePerson(follower.uri); + follower = await this.apPersonService.resolvePerson(follower.uri); + } + if (follower.alsoKnownAs) { + for (const oldUri of follower.alsoKnownAs) { + try { + await this.apPersonService.updatePerson(oldUri); + const oldAccount = await this.apPersonService.resolvePerson(oldUri); + const newUri = this.userEntityService.isRemoteUser(follower) ? follower.uri : `${this.config.url}/users/${follower.id}`; - autoAccept = oldAccount.movedToUri === newUri && await this.followingsRepository.exist({ - where: { - followeeId: followee.id, - followerId: oldAccount.id, - }, - }); - } catch { - /* skip if any error happens */ + autoAccept = oldAccount.movedToUri === newUri && await this.followingsRepository.exist({ + where: { + followeeId: followee.id, + followerId: oldAccount.id, + }, + }); + } catch { + /* skip if any error happens */ + } } } } diff --git a/packages/backend/src/core/activitypub/models/ApPersonService.ts b/packages/backend/src/core/activitypub/models/ApPersonService.ts index 3e86d3b44d..6c225de333 100644 --- a/packages/backend/src/core/activitypub/models/ApPersonService.ts +++ b/packages/backend/src/core/activitypub/models/ApPersonService.ts @@ -527,6 +527,8 @@ export class ApPersonService implements OnModuleInit { await this.updateFeatured(exist.id, resolver).catch(err => this.logger.error(err)); + this.cacheService.uriPersonCache.set(uri, Object.assign(exist, updates)); + // Copy blocking and muting if we know its moving for the first time. if (!exist.movedToUri && updates.movedToUri) { try {