This commit is contained in:
Namekuji 2023-04-15 07:27:35 -04:00
parent e900a8787e
commit 741fefbe58

View File

@ -87,7 +87,7 @@ export class UserFollowingService implements OnModuleInit {
@bindThis @bindThis
public async follow(_follower: { id: User['id'] }, _followee: { id: User['id'] }, requestId?: string, silent = false): Promise<void> { public async follow(_follower: { id: User['id'] }, _followee: { id: User['id'] }, requestId?: string, silent = false): Promise<void> {
let [follower, followee] = await Promise.all([ const [follower, followee] = await Promise.all([
this.usersRepository.findOneByOrFail({ id: _follower.id }), this.usersRepository.findOneByOrFail({ id: _follower.id }),
this.usersRepository.findOneByOrFail({ id: _followee.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. // 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 (followee.isLocked && !autoAccept) {
if (this.userEntityService.isRemoteUser(follower)) { let movedFollower = follower;
await this.apPersonService.updatePerson(follower.uri); if (this.userEntityService.isRemoteUser(movedFollower)) {
follower = await this.apPersonService.resolvePerson(follower.uri); await this.apPersonService.updatePerson(movedFollower.uri);
movedFollower = await this.apPersonService.resolvePerson(movedFollower.uri);
} }
if (follower.alsoKnownAs) { if (movedFollower.alsoKnownAs) {
for (const oldUri of follower.alsoKnownAs) { for (const oldUri of movedFollower.alsoKnownAs) {
try { try {
await this.apPersonService.updatePerson(oldUri); await this.apPersonService.updatePerson(oldUri);
const oldAccount = await this.apPersonService.resolvePerson(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({ autoAccept = oldAccount.movedToUri === newUri && await this.followingsRepository.exist({
where: { where: {