mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 23:44:33 +00:00
refactor: eliminate remaining duplicate blocks across draft streams and tests
This commit is contained in:
@@ -148,6 +148,19 @@ function resolveCaseInsensitiveAccount<T>(
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
function resolveDefaultToCaseInsensitiveAccount(params: {
|
||||
channel?:
|
||||
| {
|
||||
accounts?: Record<string, { defaultTo?: string }>;
|
||||
defaultTo?: string;
|
||||
}
|
||||
| undefined;
|
||||
accountId?: string | null;
|
||||
}): string | undefined {
|
||||
const account = resolveCaseInsensitiveAccount(params.channel?.accounts, params.accountId);
|
||||
return (account?.defaultTo ?? params.channel?.defaultTo)?.trim() || undefined;
|
||||
}
|
||||
// Channel docks: lightweight channel metadata/behavior for shared code paths.
|
||||
//
|
||||
// Rules:
|
||||
@@ -331,15 +344,7 @@ const DOCKS: Record<ChatChannelId, ChannelDock> = {
|
||||
const channel = cfg.channels?.irc as
|
||||
| { accounts?: Record<string, { defaultTo?: string }>; defaultTo?: string }
|
||||
| undefined;
|
||||
const normalized = normalizeAccountId(accountId);
|
||||
const account =
|
||||
channel?.accounts?.[normalized] ??
|
||||
channel?.accounts?.[
|
||||
Object.keys(channel?.accounts ?? {}).find(
|
||||
(key) => key.toLowerCase() === normalized.toLowerCase(),
|
||||
) ?? ""
|
||||
];
|
||||
return (account?.defaultTo ?? channel?.defaultTo)?.trim() || undefined;
|
||||
return resolveDefaultToCaseInsensitiveAccount({ channel, accountId });
|
||||
},
|
||||
},
|
||||
groups: {
|
||||
@@ -412,15 +417,7 @@ const DOCKS: Record<ChatChannelId, ChannelDock> = {
|
||||
const channel = cfg.channels?.googlechat as
|
||||
| { accounts?: Record<string, { defaultTo?: string }>; defaultTo?: string }
|
||||
| undefined;
|
||||
const normalized = normalizeAccountId(accountId);
|
||||
const account =
|
||||
channel?.accounts?.[normalized] ??
|
||||
channel?.accounts?.[
|
||||
Object.keys(channel?.accounts ?? {}).find(
|
||||
(key) => key.toLowerCase() === normalized.toLowerCase(),
|
||||
) ?? ""
|
||||
];
|
||||
return (account?.defaultTo ?? channel?.defaultTo)?.trim() || undefined;
|
||||
return resolveDefaultToCaseInsensitiveAccount({ channel, accountId });
|
||||
},
|
||||
},
|
||||
groups: {
|
||||
|
||||
Reference in New Issue
Block a user