refactor: unify onboarding dm/group policy scaffolding

This commit is contained in:
Peter Steinberger
2026-03-07 21:38:27 +00:00
parent fecca6fd8d
commit 6b1c82c4f1
20 changed files with 239 additions and 169 deletions

View File

@@ -7,11 +7,13 @@ import type {
MSTeamsTeamConfig,
} from "openclaw/plugin-sdk/msteams";
import {
addWildcardAllowFrom,
DEFAULT_ACCOUNT_ID,
formatDocsLink,
mergeAllowFromEntries,
promptChannelAccessConfig,
setTopLevelChannelAllowFrom,
setTopLevelChannelDmPolicyWithAllowFrom,
setTopLevelChannelGroupPolicy,
} from "openclaw/plugin-sdk/msteams";
import {
parseMSTeamsTeamEntry,
@@ -24,34 +26,19 @@ import { hasConfiguredMSTeamsCredentials, resolveMSTeamsCredentials } from "./to
const channel = "msteams" as const;
function setMSTeamsDmPolicy(cfg: OpenClawConfig, dmPolicy: DmPolicy) {
const allowFrom =
dmPolicy === "open"
? addWildcardAllowFrom(cfg.channels?.msteams?.allowFrom)?.map((entry) => String(entry))
: undefined;
return {
...cfg,
channels: {
...cfg.channels,
msteams: {
...cfg.channels?.msteams,
dmPolicy,
...(allowFrom ? { allowFrom } : {}),
},
},
};
return setTopLevelChannelDmPolicyWithAllowFrom({
cfg,
channel: "msteams",
dmPolicy,
});
}
function setMSTeamsAllowFrom(cfg: OpenClawConfig, allowFrom: string[]): OpenClawConfig {
return {
...cfg,
channels: {
...cfg.channels,
msteams: {
...cfg.channels?.msteams,
allowFrom,
},
},
};
return setTopLevelChannelAllowFrom({
cfg,
channel: "msteams",
allowFrom,
});
}
function parseAllowFromInput(raw: string): string[] {
@@ -171,17 +158,12 @@ function setMSTeamsGroupPolicy(
cfg: OpenClawConfig,
groupPolicy: "open" | "allowlist" | "disabled",
): OpenClawConfig {
return {
...cfg,
channels: {
...cfg.channels,
msteams: {
...cfg.channels?.msteams,
enabled: true,
groupPolicy,
},
},
};
return setTopLevelChannelGroupPolicy({
cfg,
channel: "msteams",
groupPolicy,
enabled: true,
});
}
function setMSTeamsTeamsAllowlist(