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 5141afe476
commit d5702f9d51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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();
} }