From d187e1f3addb3a62bbb4eb93d7b5c46e903ea3a9 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 10 Apr 2026 22:21:21 +0100 Subject: [PATCH] refactor: remove redundant feishu setup conversions --- extensions/feishu/src/setup-surface.ts | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/extensions/feishu/src/setup-surface.ts b/extensions/feishu/src/setup-surface.ts index 108b2d1efc8..6354f941263 100644 --- a/extensions/feishu/src/setup-surface.ts +++ b/extensions/feishu/src/setup-surface.ts @@ -111,9 +111,8 @@ function isFeishuConfigured(cfg: OpenClawConfig, accountId?: string | null): boo return hasConfiguredSecretInput(value); }; - const topLevelConfigured = Boolean( - isAppIdConfigured(feishuCfg?.appId) && hasConfiguredSecretInput(feishuCfg?.appSecret), - ); + const topLevelConfigured = + isAppIdConfigured(feishuCfg?.appId) && hasConfiguredSecretInput(feishuCfg?.appSecret); if (resolvedAccountId === DEFAULT_ACCOUNT_ID) { return topLevelConfigured; @@ -133,7 +132,7 @@ function isFeishuConfigured(cfg: OpenClawConfig, accountId?: string | null): boo ? hasConfiguredSecretInput((account as Record).appSecret) : hasConfiguredSecretInput(feishuCfg?.appSecret); - return Boolean(accountAppIdConfigured && accountSecretConfigured); + return accountAppIdConfigured && accountSecretConfigured; } async function promptFeishuAllowFrom(params: { @@ -162,10 +161,7 @@ async function promptFeishuAllowFrom(params: { initialValue: existingAllowFrom.length > 0 ? existingAllowFrom.map(String).join(", ") : undefined, }); - const mergedAllowFrom = mergeAllowFromEntries( - existingAllowFrom, - splitSetupEntries(String(entry)), - ); + const mergedAllowFrom = mergeAllowFromEntries(existingAllowFrom, splitSetupEntries(entry)); return setFeishuAllowFrom(params.cfg, params.accountId, mergedAllowFrom); } @@ -190,12 +186,12 @@ async function promptFeishuAppId(params: { prompter: Parameters>[0]["prompter"]; initialValue?: string; }): Promise { - return String( + return ( await params.prompter.text({ message: "Enter Feishu App ID", initialValue: params.initialValue, validate: (value) => (value?.trim() ? undefined : "Required"), - }), + }) ).trim(); } @@ -439,12 +435,12 @@ export const feishuSetupWizard: ChannelSetupWizard = { } const currentWebhookPath = getScopedFeishuConfig(next, resolvedAccountId).webhookPath; - const webhookPath = String( + const webhookPath = ( await prompter.text({ message: "Feishu webhook path", initialValue: currentWebhookPath ?? "/feishu/events", - validate: (value) => (String(value ?? "").trim() ? undefined : "Required"), - }), + validate: (value) => ((value ?? "").trim() ? undefined : "Required"), + }) ).trim(); next = patchFeishuConfig(next, resolvedAccountId, { webhookPath }); } @@ -485,7 +481,7 @@ export const feishuSetupWizard: ChannelSetupWizard = { initialValue: existing.length > 0 ? existing.map(String).join(", ") : undefined, }); if (entry) { - const parts = splitSetupEntries(String(entry)); + const parts = splitSetupEntries(entry); if (parts.length > 0) { next = setFeishuGroupAllowFrom(next, resolvedAccountId, parts); }