refactor(slack): reuse shared account merge helper
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import { hasConfiguredSecretInput, normalizeSecretInputString } from "../config/types.secrets.js";
|
||||
import type { SlackAccountConfig } from "../config/types.slack.js";
|
||||
import { resolveAccountEntry } from "../routing/account-lookup.js";
|
||||
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../routing/session-key.js";
|
||||
import { resolveDefaultSlackAccountId, type SlackTokenSource } from "./accounts.js";
|
||||
import {
|
||||
mergeSlackAccountConfig,
|
||||
resolveDefaultSlackAccountId,
|
||||
type SlackTokenSource,
|
||||
} from "./accounts.js";
|
||||
|
||||
export type SlackCredentialStatus = "available" | "configured_unavailable" | "missing";
|
||||
|
||||
@@ -39,21 +42,6 @@ export type InspectedSlackAccount = {
|
||||
channels?: SlackAccountConfig["channels"];
|
||||
};
|
||||
|
||||
function resolveSlackAccountConfig(
|
||||
cfg: OpenClawConfig,
|
||||
accountId: string,
|
||||
): SlackAccountConfig | undefined {
|
||||
return resolveAccountEntry(cfg.channels?.slack?.accounts, accountId);
|
||||
}
|
||||
|
||||
function mergeSlackAccountConfig(cfg: OpenClawConfig, accountId: string): SlackAccountConfig {
|
||||
const { accounts: _ignored, ...base } = (cfg.channels?.slack ?? {}) as SlackAccountConfig & {
|
||||
accounts?: unknown;
|
||||
};
|
||||
const account = resolveSlackAccountConfig(cfg, accountId) ?? {};
|
||||
return { ...base, ...account };
|
||||
}
|
||||
|
||||
function inspectSlackToken(value: unknown): {
|
||||
token?: string;
|
||||
source: Exclude<SlackTokenSource, "env">;
|
||||
|
||||
@@ -43,7 +43,10 @@ function resolveAccountConfig(
|
||||
return resolveAccountEntry(cfg.channels?.slack?.accounts, accountId);
|
||||
}
|
||||
|
||||
function mergeSlackAccountConfig(cfg: OpenClawConfig, accountId: string): SlackAccountConfig {
|
||||
export function mergeSlackAccountConfig(
|
||||
cfg: OpenClawConfig,
|
||||
accountId: string,
|
||||
): SlackAccountConfig {
|
||||
const { accounts: _ignored, ...base } = (cfg.channels?.slack ?? {}) as SlackAccountConfig & {
|
||||
accounts?: unknown;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user