From 03ed2dab868241ba5abd4d78f1f3e38a20e1dcf4 Mon Sep 17 00:00:00 2001 From: nullobsi Date: Fri, 17 Sep 2021 23:45:02 -0700 Subject: [PATCH] add resolver check for blocked instance (#7777) * add resolver check for blocked instance * lint * Update note.ts --- src/remote/activitypub/resolver.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/remote/activitypub/resolver.ts b/src/remote/activitypub/resolver.ts index 32f3d9ef2..f392a65e3 100644 --- a/src/remote/activitypub/resolver.ts +++ b/src/remote/activitypub/resolver.ts @@ -4,6 +4,8 @@ import { ILocalUser } from '@/models/entities/user'; import { getInstanceActor } from '@/services/instance-actor'; import { signedGet } from './request'; import { IObject, isCollectionOrOrderedCollection, ICollection, IOrderedCollection } from './type'; +import { fetchMeta } from '@/misc/fetch-meta'; +import { extractDbHost } from '@/misc/convert-host'; export default class Resolver { private history: Set; @@ -44,6 +46,12 @@ export default class Resolver { 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) { this.user = await getInstanceActor(); }