mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 09:41:11 +00:00
refactor: dedupe matrix record helper
This commit is contained in:
@@ -16,10 +16,7 @@ import {
|
||||
type MatrixResolvedStringField,
|
||||
} from "./auth-precedence.js";
|
||||
import { getMatrixScopedEnvVarNames, listMatrixEnvAccountIds } from "./env-vars.js";
|
||||
|
||||
function isRecord(value: unknown): value is Record<string, unknown> {
|
||||
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
||||
}
|
||||
import { isRecord } from "./record-shared.js";
|
||||
|
||||
type MatrixTopologyStringSources = Partial<Record<MatrixResolvedStringField, string>>;
|
||||
|
||||
|
||||
@@ -7,10 +7,7 @@ import {
|
||||
hasLegacyFlatAllowPrivateNetworkAlias,
|
||||
migrateLegacyFlatAllowPrivateNetworkAlias,
|
||||
} from "openclaw/plugin-sdk/ssrf-runtime";
|
||||
|
||||
function isRecord(value: unknown): value is Record<string, unknown> {
|
||||
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
||||
}
|
||||
import { isRecord } from "./record-shared.js";
|
||||
|
||||
function hasLegacyMatrixRoomAllowAlias(value: unknown): boolean {
|
||||
const room = isRecord(value) ? value : null;
|
||||
|
||||
@@ -18,10 +18,7 @@ import {
|
||||
hasPendingMatrixMigration,
|
||||
maybeCreateMatrixMigrationSnapshot,
|
||||
} from "./matrix-migration.runtime.js";
|
||||
|
||||
function isRecord(value: unknown): value is Record<string, unknown> {
|
||||
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
||||
}
|
||||
import { isRecord } from "./record-shared.js";
|
||||
|
||||
function hasConfiguredMatrixChannel(cfg: OpenClawConfig): boolean {
|
||||
const channels = cfg.channels as Record<string, unknown> | undefined;
|
||||
|
||||
3
extensions/matrix/src/record-shared.ts
Normal file
3
extensions/matrix/src/record-shared.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export function isRecord(value: unknown): value is Record<string, unknown> {
|
||||
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
||||
}
|
||||
Reference in New Issue
Block a user