activitypub: perform resolver block check on objects as well

This commit is contained in:
Norm 2022-12-24 11:58:49 -05:00
parent 85419326f8
commit 6c4a80ac24
Signed by: norm
GPG key ID: 7123E30E441E80DE

View file

@ -45,11 +45,16 @@ export class Resolver {
}
}
public async resolve(value: string | IObject, allowRedirect = false): Promise<IObject> {
public async resolve(value?: string | IObject | null, allowRedirect = false): Promise<IObject> {
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();
}