fix refollowing locked account

This commit is contained in:
Namekuji 2023-04-15 02:01:34 -04:00
parent 17c80e82e0
commit 2f5d9b86ef
2 changed files with 23 additions and 15 deletions

View file

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

View file

@ -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 {