mirror of https://github.com/openclaw/openclaw.git
fix: honor nostr setup default account
This commit is contained in:
parent
13bc70397a
commit
a89cb679a2
|
|
@ -231,6 +231,16 @@ describe("nostr setup wizard", () => {
|
|||
expect(result.cfg.channels?.nostr?.defaultAccount).toBe("work");
|
||||
expect(result.cfg.channels?.nostr?.privateKey).toBe(TEST_HEX_PRIVATE_KEY);
|
||||
});
|
||||
|
||||
it("uses configured defaultAccount when setup accountId is omitted", () => {
|
||||
expect(
|
||||
nostrPlugin.setup?.resolveAccountId?.({
|
||||
cfg: createConfiguredNostrCfg({ defaultAccount: "work" }) as OpenClawConfig,
|
||||
accountId: undefined,
|
||||
input: {},
|
||||
} as never),
|
||||
).toBe("work");
|
||||
});
|
||||
});
|
||||
|
||||
describe("nostr account helpers", () => {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import type { ChannelSetupWizard } from "openclaw/plugin-sdk/setup";
|
|||
import { formatDocsLink } from "openclaw/plugin-sdk/setup";
|
||||
import { DEFAULT_RELAYS } from "./default-relays.js";
|
||||
import { getPublicKeyFromPrivate, normalizePubkey } from "./nostr-bus.js";
|
||||
import { resolveNostrAccount } from "./types.js";
|
||||
import { resolveDefaultNostrAccountId, resolveNostrAccount } from "./types.js";
|
||||
|
||||
const channel = "nostr" as const;
|
||||
|
||||
|
|
@ -77,7 +77,7 @@ function parseNostrAllowFrom(raw: string): { entries: string[]; error?: string }
|
|||
|
||||
const promptNostrAllowFrom = createTopLevelChannelParsedAllowFromPrompt({
|
||||
channel,
|
||||
defaultAccountId: DEFAULT_ACCOUNT_ID,
|
||||
defaultAccountId: resolveDefaultNostrAccountId,
|
||||
noteTitle: "Nostr allowlist",
|
||||
noteLines: NOSTR_ALLOW_FROM_HELP_LINES,
|
||||
message: "Nostr allowFrom",
|
||||
|
|
@ -96,7 +96,7 @@ const nostrDmPolicy: ChannelSetupDmPolicy = createTopLevelChannelDmPolicy({
|
|||
});
|
||||
|
||||
export const nostrSetupAdapter: ChannelSetupAdapter = {
|
||||
resolveAccountId: ({ accountId }) => accountId?.trim() || DEFAULT_ACCOUNT_ID,
|
||||
resolveAccountId: ({ cfg, accountId }) => accountId?.trim() || resolveDefaultNostrAccountId(cfg),
|
||||
applyAccountName: ({ cfg, accountId, name }) =>
|
||||
patchTopLevelChannelConfigSection({
|
||||
cfg,
|
||||
|
|
|
|||
|
|
@ -1310,7 +1310,7 @@ export async function promptParsedAllowFromForScopedChannel(params: {
|
|||
|
||||
export function createTopLevelChannelParsedAllowFromPrompt(params: {
|
||||
channel: string;
|
||||
defaultAccountId: string;
|
||||
defaultAccountId: string | ((cfg: OpenClawConfig) => string);
|
||||
enabled?: boolean;
|
||||
noteTitle?: string;
|
||||
noteLines?: string[];
|
||||
|
|
@ -1325,7 +1325,10 @@ export function createTopLevelChannelParsedAllowFromPrompt(params: {
|
|||
...(params.enabled ? { enabled: true } : {}),
|
||||
});
|
||||
return createPromptParsedAllowFromForAccount({
|
||||
defaultAccountId: params.defaultAccountId,
|
||||
defaultAccountId:
|
||||
typeof params.defaultAccountId === "function"
|
||||
? params.defaultAccountId
|
||||
: () => params.defaultAccountId,
|
||||
...(params.noteTitle ? { noteTitle: params.noteTitle } : {}),
|
||||
...(params.noteLines ? { noteLines: params.noteLines } : {}),
|
||||
message: params.message,
|
||||
|
|
|
|||
Loading…
Reference in New Issue