mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-18 04:31:10 +00:00
test: tighten allowlist fixture typing
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user