From 6c4a80ac24d6e06d432c9012800a470be0a7fd8b Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Sat, 24 Dec 2022 11:58:49 -0500 Subject: [PATCH] activitypub: perform resolver block check on objects as well --- packages/backend/src/remote/activitypub/resolver.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/backend/src/remote/activitypub/resolver.ts b/packages/backend/src/remote/activitypub/resolver.ts index 94b8a6503..5d006d6c3 100644 --- a/packages/backend/src/remote/activitypub/resolver.ts +++ b/packages/backend/src/remote/activitypub/resolver.ts @@ -45,11 +45,16 @@ export class Resolver { } } - public async resolve(value: string | IObject, allowRedirect = false): Promise { + public async resolve(value?: string | IObject | null, allowRedirect = false): Promise { if (value == null) { throw new Error('resolvee is null (or undefined)'); } + const host = extractDbHost(typeof value === 'string' ? value : getApId(value)); + if (await shouldBlockInstance(host)) { + throw new Error('instance is blocked'); + } + if (typeof value !== 'string') { return value; } @@ -69,15 +74,10 @@ export class Resolver { } this.history.add(value); - const host = extractDbHost(value); if (isSelfHost(host)) { return await this.resolveLocal(value); } - if (await shouldBlockInstance(host)) { - throw new Error('Instance is blocked'); - } - if (!this.user) { this.user = await getInstanceActor(); }