diff --git a/packages/backend/src/misc/should-block-instance.ts b/packages/backend/src/misc/should-block-instance.ts index 7396983d7..ddd25eeee 100644 --- a/packages/backend/src/misc/should-block-instance.ts +++ b/packages/backend/src/misc/should-block-instance.ts @@ -6,11 +6,10 @@ import { Meta } from '@/models/entities/meta.js'; * Returns whether a specific host (punycoded) should be blocked. * * @param host punycoded instance host - * @param meta a Promise contatining the information from the meta table (optional) + * @param meta a resolved Meta table * @returns whether the given host should be blocked */ - -export async function shouldBlockInstance(host: Instance['host'], meta: Promise<Meta> = fetchMeta()): Promise<boolean> { - const { blockedHosts } = await meta; +export async function shouldBlockInstance(host: Instance['host'], meta?: Meta): Promise<boolean> { + const { blockedHosts } = meta ?? await fetchMeta(); return blockedHosts.some(blockedHost => host === blockedHost || host.endsWith('.' + blockedHost)); } diff --git a/packages/backend/src/misc/skipped-instances.ts b/packages/backend/src/misc/skipped-instances.ts index f5b5c3b73..1772ac878 100644 --- a/packages/backend/src/misc/skipped-instances.ts +++ b/packages/backend/src/misc/skipped-instances.ts @@ -16,7 +16,7 @@ const deadThreshold = 7 * DAY; */ export async function skippedInstances(hosts: Array<Instance['host']>): Promise<Array<Instance['host']>> { // Resolve the boolean promises before filtering - const meta = fetchMeta(); + const meta = await fetchMeta(); const shouldSkip = await Promise.all(hosts.map(host => shouldBlockInstance(host, meta))); const skipped = hosts.filter((_, i) => shouldSkip[i]);