add resolver check for blocked instance (#7777)

* add resolver check for blocked instance

* lint

* Update note.ts
This commit is contained in:
nullobsi 2021-09-17 23:45:02 -07:00 committed by GitHub
parent 6176a1ad40
commit 03ed2dab86

View file

@ -4,6 +4,8 @@ import { ILocalUser } from '@/models/entities/user';
import { getInstanceActor } from '@/services/instance-actor'; import { getInstanceActor } from '@/services/instance-actor';
import { signedGet } from './request'; import { signedGet } from './request';
import { IObject, isCollectionOrOrderedCollection, ICollection, IOrderedCollection } from './type'; import { IObject, isCollectionOrOrderedCollection, ICollection, IOrderedCollection } from './type';
import { fetchMeta } from '@/misc/fetch-meta';
import { extractDbHost } from '@/misc/convert-host';
export default class Resolver { export default class Resolver {
private history: Set<string>; private history: Set<string>;
@ -44,6 +46,12 @@ export default class Resolver {
this.history.add(value); this.history.add(value);
const meta = await fetchMeta();
const host = extractDbHost(value);
if (meta.blockedHosts.includes(host)) {
throw new Error('Instance is blocked');
}
if (config.signToActivityPubGet && !this.user) { if (config.signToActivityPubGet && !this.user) {
this.user = await getInstanceActor(); this.user = await getInstanceActor();
} }