mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 00:07:27 +00:00
Matrix: show account-scoped onboarding paths
This commit is contained in:
@@ -263,4 +263,35 @@ describe("matrix onboarding", () => {
|
||||
expect(result.cfg.channels?.["matrix"]?.dm).toBeUndefined();
|
||||
expect(result.cfg.channels?.["matrix"]?.groups).toBeUndefined();
|
||||
});
|
||||
|
||||
it("reports account-scoped DM config keys for named accounts", () => {
|
||||
const resolveConfigKeys = matrixOnboardingAdapter.dmPolicy?.resolveConfigKeys;
|
||||
expect(resolveConfigKeys).toBeDefined();
|
||||
if (!resolveConfigKeys) {
|
||||
return;
|
||||
}
|
||||
|
||||
expect(
|
||||
resolveConfigKeys(
|
||||
{
|
||||
channels: {
|
||||
matrix: {
|
||||
accounts: {
|
||||
default: {
|
||||
homeserver: "https://matrix.main.example.org",
|
||||
},
|
||||
ops: {
|
||||
homeserver: "https://matrix.ops.example.org",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
} as CoreConfig,
|
||||
"ops",
|
||||
),
|
||||
).toEqual({
|
||||
policyKey: "channels.matrix.accounts.ops.dm.policy",
|
||||
allowFromKey: "channels.matrix.accounts.ops.dm.allowFrom",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -24,7 +24,7 @@ import {
|
||||
hasReadyMatrixEnvAuth,
|
||||
resolveScopedMatrixEnvConfig,
|
||||
} from "./matrix/client.js";
|
||||
import { updateMatrixAccountConfig } from "./matrix/config-update.js";
|
||||
import { resolveMatrixConfigPath, updateMatrixAccountConfig } from "./matrix/config-update.js";
|
||||
import { ensureMatrixSdkInstalled, isMatrixSdkAvailable } from "./matrix/deps.js";
|
||||
import { resolveMatrixTargets } from "./resolve-targets.js";
|
||||
import type { CoreConfig } from "./types.js";
|
||||
@@ -175,6 +175,16 @@ const dmPolicy: ChannelOnboardingDmPolicy = {
|
||||
channel,
|
||||
policyKey: "channels.matrix.dm.policy",
|
||||
allowFromKey: "channels.matrix.dm.allowFrom",
|
||||
resolveConfigKeys: (cfg, accountId) => {
|
||||
const basePath = resolveMatrixConfigPath(
|
||||
cfg as CoreConfig,
|
||||
resolveMatrixOnboardingAccountId(cfg as CoreConfig, accountId),
|
||||
);
|
||||
return {
|
||||
policyKey: `${basePath}.dm.policy`,
|
||||
allowFromKey: `${basePath}.dm.allowFrom`,
|
||||
};
|
||||
},
|
||||
getCurrent: (cfg, accountId) =>
|
||||
resolveMatrixAccountConfig({
|
||||
cfg: cfg as CoreConfig,
|
||||
|
||||
Reference in New Issue
Block a user