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 @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> {
const [follower, followee] = await Promise.all([ let [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 }),
]); ]);
@ -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. // 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) { if (followee.isLocked && !autoAccept) {
for (const oldUri of follower.alsoKnownAs) { if (this.userEntityService.isRemoteUser(follower)) {
try { await this.apPersonService.updatePerson(follower.uri);
await this.apPersonService.updatePerson(oldUri); follower = await this.apPersonService.resolvePerson(follower.uri);
const oldAccount = await this.apPersonService.resolvePerson(oldUri); }
const newUri = this.userEntityService.isRemoteUser(follower) ? follower.uri : `${this.config.url}/users/${follower.id}`; 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({ autoAccept = oldAccount.movedToUri === newUri && await this.followingsRepository.exist({
where: { where: {
followeeId: followee.id, followeeId: followee.id,
followerId: oldAccount.id, followerId: oldAccount.id,
}, },
}); });
} catch { } catch {
/* skip if any error happens */ /* 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)); 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. // Copy blocking and muting if we know its moving for the first time.
if (!exist.movedToUri && updates.movedToUri) { if (!exist.movedToUri && updates.movedToUri) {
try { try {