server: fix error about duplicate resolve

This commit is contained in:
Johann150 2022-12-15 19:44:55 +01:00
parent 84d83d908a
commit 8c759dde6c
Signed by untrusted user: Johann150
GPG key ID: 9EE6577A2A06F8F1
2 changed files with 6 additions and 8 deletions

View file

@ -129,14 +129,12 @@ export async function fetchPerson(uri: string, resolver: Resolver): Promise<Cach
/**
* Personを作成します
*/
export async function createPerson(uri: string, resolver: Resolver): Promise<User> {
if (typeof uri !== 'string') throw new Error('uri is not string');
if (uri.startsWith(config.url)) {
export async function createPerson(value: string | IObject, resolver: Resolver): Promise<User> {
if (getApId(value).startsWith(config.url)) {
throw new StatusError('cannot resolve local user', 400, 'cannot resolve local user');
}
const object = await resolver.resolve(uri) as any;
const object = await resolver.resolve(value) as any;
const person = validateActor(object);
@ -272,7 +270,7 @@ export async function createPerson(uri: string, resolver: Resolver): Promise<Use
/**
* Update Person information.
* If the target Person is not registered in FoundKey, it is ignored.
* @param uri URI of Person
* @param value URI of Person or Person itself
* @param resolver Resolver
* @param hint Hint of Person object (If this value is a valid Person, it is used for updating without Remote resolve.)
*/

View file

@ -114,8 +114,8 @@ async function fetchAny(uri: string, me: CacheableLocalUser | null | undefined):
return await mergePack(
me,
isActor(object) ? await createPerson(getApId(object), resolver) : null,
isPost(object) ? await createNote(getApId(object), resolver, true) : null,
isActor(object) ? await createPerson(object, resolver) : null,
isPost(object) ? await createNote(object, resolver, true) : null,
);
}