mirror of https://github.com/openclaw/openclaw.git
fix: honor googlechat default account setup policy
This commit is contained in:
parent
acfa09679c
commit
d0a43cf8c0
|
|
@ -42,11 +42,11 @@ const googlechatDmPolicy: ChannelSetupDmPolicy = {
|
|||
channel,
|
||||
policyKey: "channels.googlechat.dm.policy",
|
||||
allowFromKey: "channels.googlechat.dm.allowFrom",
|
||||
resolveConfigKeys: (_cfg, accountId) =>
|
||||
accountId && accountId !== DEFAULT_ACCOUNT_ID
|
||||
resolveConfigKeys: (cfg, accountId) =>
|
||||
(accountId ?? resolveDefaultGoogleChatAccountId(cfg)) !== DEFAULT_ACCOUNT_ID
|
||||
? {
|
||||
policyKey: `channels.googlechat.accounts.${accountId}.dm.policy`,
|
||||
allowFromKey: `channels.googlechat.accounts.${accountId}.dm.allowFrom`,
|
||||
policyKey: `channels.googlechat.accounts.${accountId ?? resolveDefaultGoogleChatAccountId(cfg)}.dm.policy`,
|
||||
allowFromKey: `channels.googlechat.accounts.${accountId ?? resolveDefaultGoogleChatAccountId(cfg)}.dm.allowFrom`,
|
||||
}
|
||||
: {
|
||||
policyKey: "channels.googlechat.dm.policy",
|
||||
|
|
@ -55,10 +55,10 @@ const googlechatDmPolicy: ChannelSetupDmPolicy = {
|
|||
getCurrent: (cfg, accountId) =>
|
||||
resolveGoogleChatAccount({
|
||||
cfg,
|
||||
accountId: accountId ?? DEFAULT_ACCOUNT_ID,
|
||||
accountId: accountId ?? resolveDefaultGoogleChatAccountId(cfg),
|
||||
}).config.dm?.policy ?? "pairing",
|
||||
setPolicy: (cfg, policy, accountId) => {
|
||||
const resolvedAccountId = accountId ?? DEFAULT_ACCOUNT_ID;
|
||||
const resolvedAccountId = accountId ?? resolveDefaultGoogleChatAccountId(cfg);
|
||||
const currentDm = resolveGoogleChatAccount({
|
||||
cfg,
|
||||
accountId: resolvedAccountId,
|
||||
|
|
|
|||
|
|
@ -218,6 +218,37 @@ describe("googlechat setup", () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("uses configured defaultAccount for omitted DM policy account context", () => {
|
||||
const cfg = {
|
||||
channels: {
|
||||
googlechat: {
|
||||
defaultAccount: "alerts",
|
||||
dm: {
|
||||
policy: "disabled",
|
||||
},
|
||||
accounts: {
|
||||
alerts: {
|
||||
serviceAccount: { client_email: "bot@example.com" },
|
||||
dm: {
|
||||
policy: "allowlist",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
} as OpenClawConfig;
|
||||
|
||||
expect(googlechatPlugin.setupWizard?.dmPolicy?.getCurrent(cfg)).toBe("allowlist");
|
||||
expect(googlechatPlugin.setupWizard?.dmPolicy?.resolveConfigKeys?.(cfg)).toEqual({
|
||||
policyKey: "channels.googlechat.accounts.alerts.dm.policy",
|
||||
allowFromKey: "channels.googlechat.accounts.alerts.dm.allowFrom",
|
||||
});
|
||||
|
||||
const next = googlechatPlugin.setupWizard?.dmPolicy?.setPolicy(cfg, "open");
|
||||
expect(next?.channels?.googlechat?.dm?.policy).toBe("disabled");
|
||||
expect(next?.channels?.googlechat?.accounts?.alerts?.dm?.policy).toBe("open");
|
||||
});
|
||||
|
||||
it('writes open DM policy to the named account and preserves inherited allowFrom with "*"', () => {
|
||||
const next = googlechatPlugin.setupWizard?.dmPolicy?.setPolicy(
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue