mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 07:20:45 +00:00
refactor: share onboarding account id resolution prelude
This commit is contained in:
@@ -23,6 +23,10 @@ vi.mock("openclaw/plugin-sdk/bluebubbles", () => ({
|
||||
);
|
||||
},
|
||||
mergeAllowFromEntries: (_existing: unknown, entries: string[]) => entries,
|
||||
createAccountListHelpers: () => ({
|
||||
listAccountIds: () => ["default"],
|
||||
resolveDefaultAccountId: () => "default",
|
||||
}),
|
||||
normalizeSecretInputString: (value: unknown) => {
|
||||
if (typeof value !== "string") {
|
||||
return undefined;
|
||||
@@ -33,6 +37,10 @@ vi.mock("openclaw/plugin-sdk/bluebubbles", () => ({
|
||||
normalizeAccountId: (value?: string | null) =>
|
||||
value && value.trim().length > 0 ? value : "default",
|
||||
promptAccountId: vi.fn(),
|
||||
resolveAccountIdForConfigure: async (params: {
|
||||
accountOverride?: string;
|
||||
defaultAccountId: string;
|
||||
}) => params.accountOverride?.trim() || params.defaultAccountId,
|
||||
}));
|
||||
|
||||
describe("bluebubbles onboarding SecretInput", () => {
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
formatDocsLink,
|
||||
mergeAllowFromEntries,
|
||||
normalizeAccountId,
|
||||
promptAccountId,
|
||||
resolveAccountIdForConfigure,
|
||||
} from "openclaw/plugin-sdk/bluebubbles";
|
||||
import {
|
||||
listBlueBubblesAccountIds,
|
||||
@@ -160,21 +160,16 @@ export const blueBubblesOnboardingAdapter: ChannelOnboardingAdapter = {
|
||||
};
|
||||
},
|
||||
configure: async ({ cfg, prompter, accountOverrides, shouldPromptAccountIds }) => {
|
||||
const blueBubblesOverride = accountOverrides.bluebubbles?.trim();
|
||||
const defaultAccountId = resolveDefaultBlueBubblesAccountId(cfg);
|
||||
let accountId = blueBubblesOverride
|
||||
? normalizeAccountId(blueBubblesOverride)
|
||||
: defaultAccountId;
|
||||
if (shouldPromptAccountIds && !blueBubblesOverride) {
|
||||
accountId = await promptAccountId({
|
||||
cfg,
|
||||
prompter,
|
||||
label: "BlueBubbles",
|
||||
currentId: accountId,
|
||||
listAccountIds: listBlueBubblesAccountIds,
|
||||
defaultAccountId,
|
||||
});
|
||||
}
|
||||
const accountId = await resolveAccountIdForConfigure({
|
||||
cfg,
|
||||
prompter,
|
||||
label: "BlueBubbles",
|
||||
accountOverride: accountOverrides.bluebubbles,
|
||||
shouldPromptAccountIds,
|
||||
listAccountIds: listBlueBubblesAccountIds,
|
||||
defaultAccountId,
|
||||
});
|
||||
|
||||
let next = cfg;
|
||||
const resolvedAccount = resolveBlueBubblesAccount({ cfg: next, accountId });
|
||||
|
||||
Reference in New Issue
Block a user