perf(telegram): lazy import proxy + timeout deps in audit

This commit is contained in:
Peter Steinberger
2026-02-15 13:44:46 +00:00
parent a4b958efcd
commit a8f3a579d4

View File

@@ -1,7 +1,5 @@
import type { TelegramGroupConfig } from "../config/types.js";
import { isRecord } from "../utils.js";
import { fetchWithTimeout } from "../utils/fetch-timeout.js";
import { makeProxyFetch } from "./proxy.js";
const TELEGRAM_API_BASE = "https://api.telegram.org";
@@ -87,7 +85,12 @@ export async function auditTelegramGroupMembership(params: {
};
}
const fetcher = params.proxyUrl ? makeProxyFetch(params.proxyUrl) : fetch;
// Lazy import to avoid pulling `undici` (ProxyAgent) into cold-path callers that only need
// `collectTelegramUnmentionedGroupIds` (e.g. config audits).
const fetcher = params.proxyUrl
? (await import("./proxy.js")).makeProxyFetch(params.proxyUrl)
: fetch;
const { fetchWithTimeout } = await import("../utils/fetch-timeout.js");
const base = `${TELEGRAM_API_BASE}/bot${token}`;
const groups: TelegramGroupMembershipAuditEntry[] = [];