fix ImmediateApPersonService producing duplicate calls to updateFeatured

This commit is contained in:
Hazelnoot 2025-07-09 18:20:59 -04:00
parent 7b809b2b58
commit a903d77a3f

View file

@ -3,42 +3,25 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
import type { IObject } from '@/core/activitypub/type.js';
import { ApPersonService } from '@/core/activitypub/models/ApPersonService.js';
import { MiRemoteUser, MiUser } from '@/models/User.js';
import { MiUser } from '@/models/User.js';
import { FetchInstanceMetadataService } from '@/core/FetchInstanceMetadataService.js';
import { MiInstance } from '@/models/Instance.js';
import { Resolver } from '@/core/activitypub/ApResolverService.js';
import { bindThis } from '@/decorators.js';
export class ImmediateApPersonService extends ApPersonService {
@bindThis
async createPerson(uri: string, resolver?: Resolver): Promise<MiRemoteUser> {
const user = await super.createPerson(uri, resolver);
await this.updateFeatured(user, resolver);
return user;
}
@bindThis
async updatePerson(uri: string, resolver?: Resolver | null, hint?: IObject, movePreventUris: string[] = []): Promise<string | void> {
const result = await super.updatePerson(uri, resolver, hint, movePreventUris);
const user = await this.fetchPerson(uri);
if (user == null) throw new Error('updated user is null, did you forget to mock out caches?');
await this.updateFeatured(user, resolver ?? undefined);
return result;
}
public resolver?: Resolver;
@bindThis
async updatePersonLazy(uriOrUser: string | MiUser): Promise<void> {
const userId = typeof(uriOrUser) === 'object' ? uriOrUser.id : uriOrUser;
await this.updatePerson(userId);
await this.updatePerson(userId, this.resolver);
}
@bindThis
async updateFeaturedLazy(userOrId: string | MiUser): Promise<void> {
await this.updateFeatured(userOrId);
await this.updateFeatured(userOrId, this.resolver);
}
}