mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 02:31:22 +00:00
refactor(channels): share account summary helpers
This commit is contained in:
36
src/channels/account-summary.ts
Normal file
36
src/channels/account-summary.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import type { ChannelAccountSnapshot } from "./plugins/types.core.js";
|
||||
import type { ChannelPlugin } from "./plugins/types.plugin.js";
|
||||
|
||||
export function buildChannelAccountSnapshot(params: {
|
||||
plugin: ChannelPlugin;
|
||||
account: unknown;
|
||||
cfg: OpenClawConfig;
|
||||
accountId: string;
|
||||
enabled: boolean;
|
||||
configured: boolean;
|
||||
}): ChannelAccountSnapshot {
|
||||
const described = params.plugin.config.describeAccount?.(params.account, params.cfg);
|
||||
return {
|
||||
enabled: params.enabled,
|
||||
configured: params.configured,
|
||||
...described,
|
||||
accountId: params.accountId,
|
||||
};
|
||||
}
|
||||
|
||||
export function formatChannelAllowFrom(params: {
|
||||
plugin: ChannelPlugin;
|
||||
cfg: OpenClawConfig;
|
||||
accountId?: string | null;
|
||||
allowFrom: Array<string | number>;
|
||||
}): string[] {
|
||||
if (params.plugin.config.formatAllowFrom) {
|
||||
return params.plugin.config.formatAllowFrom({
|
||||
cfg: params.cfg,
|
||||
accountId: params.accountId,
|
||||
allowFrom: params.allowFrom,
|
||||
});
|
||||
}
|
||||
return params.allowFrom.map((entry) => String(entry).trim()).filter(Boolean);
|
||||
}
|
||||
Reference in New Issue
Block a user