test: tighten allowlist fixture typing

This commit is contained in:
Peter Steinberger
2026-04-06 04:43:03 +01:00
parent 4aeabf95cc
commit 9f8900bb3c

View File

@@ -46,6 +46,14 @@ type TelegramTestSectionConfig = {
accounts?: Record<string, TelegramTestSectionConfig>;
};
type DmGroupAllowlistTestSectionConfig = {
allowFrom?: string[];
groupAllowFrom?: string[];
dm?: {
allowFrom?: string[];
};
};
function normalizeTelegramAllowFromEntries(values: Array<string | number>): string[] {
return formatAllowFromLowercase({ allowFrom: values, stripPrefixRe: /^(telegram|tg):/i });
}
@@ -117,7 +125,8 @@ const whatsappAllowlistTestPlugin: ChannelPlugin = {
},
allowlist: buildDmGroupAccountAllowlistAdapter({
channelId: "whatsapp",
resolveAccount: ({ cfg }) => (cfg.channels?.whatsapp as Record<string, unknown>) ?? {},
resolveAccount: ({ cfg }) =>
(cfg.channels?.whatsapp as DmGroupAllowlistTestSectionConfig | undefined) ?? {},
normalize: ({ values }) => values.map((value) => String(value).trim()).filter(Boolean),
resolveDmAllowFrom: (account) => account.allowFrom,
resolveGroupAllowFrom: (account) => account.groupAllowFrom,
@@ -143,7 +152,7 @@ function createLegacyAllowlistPlugin(channelId: "discord" | "slack"): ChannelPlu
allowlist: buildLegacyDmAccountAllowlistAdapter({
channelId,
resolveAccount: ({ cfg }) =>
(cfg.channels?.[channelId] as Record<string, unknown> | undefined) ?? {},
(cfg.channels?.[channelId] as DmGroupAllowlistTestSectionConfig | undefined) ?? {},
normalize: ({ values }) => values.map((value) => String(value).trim()).filter(Boolean),
resolveDmAllowFrom: (account) => account.allowFrom ?? account.dm?.allowFrom,
resolveGroupPolicy: () => undefined,