diff --git a/extensions/matrix/src/matrix/active-client.ts b/extensions/matrix/src/matrix/active-client.ts index a643f343b..0f309d395 100644 --- a/extensions/matrix/src/matrix/active-client.ts +++ b/extensions/matrix/src/matrix/active-client.ts @@ -1,5 +1,5 @@ import type { MatrixClient } from "@vector-im/matrix-bot-sdk"; -import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk"; +import { normalizeAccountId } from "openclaw/plugin-sdk"; // Support multiple active clients for multi-account const activeClients = new Map(); @@ -8,7 +8,7 @@ export function setActiveMatrixClient( client: MatrixClient | null, accountId?: string | null, ): void { - const key = accountId ?? DEFAULT_ACCOUNT_ID; + const key = normalizeAccountId(accountId); if (client) { activeClients.set(key, client); } else { @@ -17,7 +17,7 @@ export function setActiveMatrixClient( } export function getActiveMatrixClient(accountId?: string | null): MatrixClient | null { - const key = accountId ?? DEFAULT_ACCOUNT_ID; + const key = normalizeAccountId(accountId); return activeClients.get(key) ?? null; } diff --git a/extensions/matrix/src/matrix/send/client.ts b/extensions/matrix/src/matrix/send/client.ts index c1ea1a65b..c1938d4c3 100644 --- a/extensions/matrix/src/matrix/send/client.ts +++ b/extensions/matrix/src/matrix/send/client.ts @@ -1,4 +1,5 @@ import type { MatrixClient } from "@vector-im/matrix-bot-sdk"; +import { normalizeAccountId } from "openclaw/plugin-sdk"; import type { CoreConfig } from "../../types.js"; import { getMatrixRuntime } from "../../runtime.js"; import { getActiveMatrixClient, getAnyActiveMatrixClient } from "../active-client.js"; @@ -19,12 +20,11 @@ export function ensureNodeRuntime() { export function resolveMediaMaxBytes(accountId?: string): number | undefined { const cfg = getCore().config.loadConfig() as CoreConfig; - // Check account-specific config first - if (accountId) { - const accountConfig = cfg.channels?.matrix?.accounts?.[accountId]; - if (typeof accountConfig?.mediaMaxMb === "number") { - return accountConfig.mediaMaxMb * 1024 * 1024; - } + // Check account-specific config first (normalize to ensure consistent keying) + const normalized = normalizeAccountId(accountId); + const accountConfig = cfg.channels?.matrix?.accounts?.[normalized]; + if (typeof accountConfig?.mediaMaxMb === "number") { + return accountConfig.mediaMaxMb * 1024 * 1024; } // Fall back to top-level config if (typeof cfg.channels?.matrix?.mediaMaxMb === "number") {