fix: honor matrix default runtime account

This commit is contained in:
Tak Hoffman
2026-04-03 13:26:28 -05:00
parent eea069bdc3
commit 24a4ed1013
2 changed files with 26 additions and 1 deletions

View File

@@ -218,6 +218,29 @@ describe("resolveMatrixAccount", () => {
expect(resolveDefaultMatrixAccountId(cfg)).toBe("ops");
});
it("uses configured defaultAccount when accountId is omitted", () => {
const cfg: CoreConfig = {
channels: {
matrix: {
defaultAccount: "ops",
homeserver: "https://matrix.example.org",
accessToken: "default-token",
accounts: {
ops: {
homeserver: "https://ops.example.org",
accessToken: "ops-token",
},
},
},
},
};
const account = resolveMatrixAccount({ cfg });
expect(account.accountId).toBe("ops");
expect(account.homeserver).toBe("https://ops.example.org");
expect(account.configured).toBe(true);
});
it("includes env-backed named accounts in plugin account enumeration", () => {
const keys = getMatrixScopedEnvVarNames("team-ops");
process.env[keys.homeserver] = "https://matrix.example.org";

View File

@@ -179,7 +179,9 @@ export function resolveMatrixAccount(params: {
env?: NodeJS.ProcessEnv;
}): ResolvedMatrixAccount {
const env = params.env ?? process.env;
const accountId = normalizeAccountId(params.accountId);
const accountId = normalizeAccountId(
params.accountId ?? resolveDefaultMatrixAccountId(params.cfg),
);
const matrixBase = resolveMatrixBaseConfig(params.cfg);
const base = resolveMatrixAccountConfig({ cfg: params.cfg, accountId, env });
const explicitAuthConfig =