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
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: _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: {