mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-23 10:27:28 -07:00
20 lines
644 B
TypeScript
20 lines
644 B
TypeScript
import { fetchMeta } from "@/misc/fetch-meta.js";
|
|
import type { Instance } from "@/models/entities/instance.js";
|
|
import type { Meta } from "@/models/entities/meta.js";
|
|
|
|
/**
|
|
* Returns whether a specific host (punycoded) should be blocked.
|
|
*
|
|
* @param host punycoded instance host
|
|
* @param meta a resolved Meta table
|
|
* @returns whether the given host should be blocked
|
|
*/
|
|
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}`),
|
|
);
|
|
}
|