refactor: remove redundant feishu setup conversions

This commit is contained in:
Peter Steinberger
2026-04-10 22:21:21 +01:00
parent efd6da136d
commit d187e1f3ad

View File

@@ -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<string, unknown>).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<NonNullable<ChannelSetupWizard["finalize"]>>[0]["prompter"];
initialValue?: string;
}): Promise<string> {
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);
}