mirror of
https://github.com/farcasclaudiu/openclaw.git
synced 2026-06-28 21:01:43 +03:00
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 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
|
// Support multiple active clients for multi-account
|
||||||
const activeClients = new Map<string, MatrixClient>();
|
const activeClients = new Map<string, MatrixClient>();
|
||||||
@@ -8,7 +8,7 @@ export function setActiveMatrixClient(
|
|||||||
client: MatrixClient | null,
|
client: MatrixClient | null,
|
||||||
accountId?: string | null,
|
accountId?: string | null,
|
||||||
): void {
|
): void {
|
||||||
const key = accountId ?? DEFAULT_ACCOUNT_ID;
|
const key = normalizeAccountId(accountId);
|
||||||
if (client) {
|
if (client) {
|
||||||
activeClients.set(key, client);
|
activeClients.set(key, client);
|
||||||
} else {
|
} else {
|
||||||
@@ -17,7 +17,7 @@ export function setActiveMatrixClient(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getActiveMatrixClient(accountId?: string | null): MatrixClient | null {
|
export function getActiveMatrixClient(accountId?: string | null): MatrixClient | null {
|
||||||
const key = accountId ?? DEFAULT_ACCOUNT_ID;
|
const key = normalizeAccountId(accountId);
|
||||||
return activeClients.get(key) ?? null;
|
return activeClients.get(key) ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import type { MatrixClient } from "@vector-im/matrix-bot-sdk";
|
import type { MatrixClient } from "@vector-im/matrix-bot-sdk";
|
||||||
|
import { normalizeAccountId } from "openclaw/plugin-sdk";
|
||||||
import type { CoreConfig } from "../../types.js";
|
import type { CoreConfig } from "../../types.js";
|
||||||
import { getMatrixRuntime } from "../../runtime.js";
|
import { getMatrixRuntime } from "../../runtime.js";
|
||||||
import { getActiveMatrixClient, getAnyActiveMatrixClient } from "../active-client.js";
|
import { getActiveMatrixClient, getAnyActiveMatrixClient } from "../active-client.js";
|
||||||
@@ -19,12 +20,11 @@ export function ensureNodeRuntime() {
|
|||||||
|
|
||||||
export function resolveMediaMaxBytes(accountId?: string): number | undefined {
|
export function resolveMediaMaxBytes(accountId?: string): number | undefined {
|
||||||
const cfg = getCore().config.loadConfig() as CoreConfig;
|
const cfg = getCore().config.loadConfig() as CoreConfig;
|
||||||
// Check account-specific config first
|
// Check account-specific config first (normalize to ensure consistent keying)
|
||||||
if (accountId) {
|
const normalized = normalizeAccountId(accountId);
|
||||||
const accountConfig = cfg.channels?.matrix?.accounts?.[accountId];
|
const accountConfig = cfg.channels?.matrix?.accounts?.[normalized];
|
||||||
if (typeof accountConfig?.mediaMaxMb === "number") {
|
if (typeof accountConfig?.mediaMaxMb === "number") {
|
||||||
return accountConfig.mediaMaxMb * 1024 * 1024;
|
return accountConfig.mediaMaxMb * 1024 * 1024;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Fall back to top-level config
|
// Fall back to top-level config
|
||||||
if (typeof cfg.channels?.matrix?.mediaMaxMb === "number") {
|
if (typeof cfg.channels?.matrix?.mediaMaxMb === "number") {
|
||||||
|
|||||||
Reference in New Issue
Block a user