server: fix error about duplicate resolve
All checks were successful
ci/woodpecker/push/lint-backend Pipeline was successful
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/push/lint-client Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-sw Pipeline was successful
ci/woodpecker/push/test Pipeline was successful

This commit is contained in:
Johann150 2022-12-15 19:44:55 +01:00
parent 84d83d908a
commit 8c759dde6c
Signed by: 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を作成します * Personを作成します
*/ */
export async function createPerson(uri: string, resolver: Resolver): Promise<User> { export async function createPerson(value: string | IObject, resolver: Resolver): Promise<User> {
if (typeof uri !== 'string') throw new Error('uri is not string'); if (getApId(value).startsWith(config.url)) {
if (uri.startsWith(config.url)) {
throw new StatusError('cannot resolve local user', 400, 'cannot resolve local user'); 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); const person = validateActor(object);
@ -272,7 +270,7 @@ export async function createPerson(uri: string, resolver: Resolver): Promise<Use
/** /**
* Update Person information. * Update Person information.
* If the target Person is not registered in FoundKey, it is ignored. * 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 resolver Resolver
* @param hint Hint of Person object (If this value is a valid Person, it is used for updating without Remote resolve.) * @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( return await mergePack(
me, me,
isActor(object) ? await createPerson(getApId(object), resolver) : null, isActor(object) ? await createPerson(object, resolver) : null,
isPost(object) ? await createNote(getApId(object), resolver, true) : null, isPost(object) ? await createNote(object, resolver, true) : null,
); );
} }