fix: normalize accountId in active-client and send/client for consistent keying
This commit is contained in:
committed by
Peter Steinberger
parent
caf5d2dd7c
commit
c89b8d99fc
@@ -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<string, MatrixClient>();
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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") {
|
||||
|
||||
Reference in New Issue
Block a user