mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-04 03:50:23 +00:00
fix: honor account-scoped setup dm policy
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import {
|
||||
addWildcardAllowFrom,
|
||||
createAllowFromSection,
|
||||
createTopLevelChannelDmPolicy,
|
||||
createStandardChannelSetupStatus,
|
||||
type ChannelSetupDmPolicy,
|
||||
DEFAULT_ACCOUNT_ID,
|
||||
hasConfiguredSecretInput,
|
||||
type OpenClawConfig,
|
||||
@@ -76,14 +77,40 @@ function buildTelegramDmAccessWarningLines(accountId: string): string[] {
|
||||
];
|
||||
}
|
||||
|
||||
const dmPolicy = createTopLevelChannelDmPolicy({
|
||||
const dmPolicy: ChannelSetupDmPolicy = {
|
||||
label: "Telegram",
|
||||
channel,
|
||||
policyKey: "channels.telegram.dmPolicy",
|
||||
allowFromKey: "channels.telegram.allowFrom",
|
||||
getCurrent: (cfg) => cfg.channels?.telegram?.dmPolicy ?? "pairing",
|
||||
resolveConfigKeys: (_cfg, accountId) =>
|
||||
accountId && accountId !== DEFAULT_ACCOUNT_ID
|
||||
? {
|
||||
policyKey: `channels.telegram.accounts.${accountId}.dmPolicy`,
|
||||
allowFromKey: `channels.telegram.accounts.${accountId}.allowFrom`,
|
||||
}
|
||||
: {
|
||||
policyKey: "channels.telegram.dmPolicy",
|
||||
allowFromKey: "channels.telegram.allowFrom",
|
||||
},
|
||||
getCurrent: (cfg, accountId) =>
|
||||
mergeTelegramAccountConfig(cfg, accountId ?? DEFAULT_ACCOUNT_ID).dmPolicy ?? "pairing",
|
||||
setPolicy: (cfg, policy, accountId) => {
|
||||
const resolvedAccountId = accountId ?? DEFAULT_ACCOUNT_ID;
|
||||
const merged = mergeTelegramAccountConfig(cfg, resolvedAccountId);
|
||||
return patchChannelConfigForAccount({
|
||||
cfg,
|
||||
channel,
|
||||
accountId: resolvedAccountId,
|
||||
patch: {
|
||||
dmPolicy: policy,
|
||||
...(policy === "open"
|
||||
? { allowFrom: addWildcardAllowFrom(merged.allowFrom) }
|
||||
: {}),
|
||||
},
|
||||
});
|
||||
},
|
||||
promptAllowFrom: promptTelegramAllowFromForAccount,
|
||||
});
|
||||
};
|
||||
|
||||
export const telegramSetupWizard: ChannelSetupWizard = {
|
||||
channel,
|
||||
|
||||
Reference in New Issue
Block a user