diff --git a/packages/backend/src/core/UserFollowingService.ts b/packages/backend/src/core/UserFollowingService.ts index b7c7536651..8a1026f6e3 100644 --- a/packages/backend/src/core/UserFollowingService.ts +++ b/packages/backend/src/core/UserFollowingService.ts @@ -87,7 +87,7 @@ export class UserFollowingService implements OnModuleInit { @bindThis public async follow(_follower: { id: User['id'] }, _followee: { id: User['id'] }, requestId?: string, silent = false): Promise { - let [follower, followee] = await Promise.all([ + const [follower, followee] = await Promise.all([ this.usersRepository.findOneByOrFail({ id: _follower.id }), this.usersRepository.findOneByOrFail({ id: _followee.id }), ]); @@ -142,16 +142,17 @@ 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) { - if (this.userEntityService.isRemoteUser(follower)) { - await this.apPersonService.updatePerson(follower.uri); - follower = await this.apPersonService.resolvePerson(follower.uri); + let movedFollower = follower; + if (this.userEntityService.isRemoteUser(movedFollower)) { + await this.apPersonService.updatePerson(movedFollower.uri); + movedFollower = await this.apPersonService.resolvePerson(movedFollower.uri); } - if (follower.alsoKnownAs) { - for (const oldUri of follower.alsoKnownAs) { + if (movedFollower.alsoKnownAs) { + for (const oldUri of movedFollower.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}`; + const newUri = this.userEntityService.isRemoteUser(movedFollower) ? movedFollower.uri : `${this.config.url}/users/${movedFollower.id}`; autoAccept = oldAccount.movedToUri === newUri && await this.followingsRepository.exist({ where: {