refactor(outbound): share thread id normalization

This commit is contained in:
Peter Steinberger
2026-03-17 03:56:17 +00:00
parent 233ef31190
commit 6a27db0cd7
6 changed files with 38 additions and 57 deletions

View File

@@ -31,6 +31,7 @@ import {
type OutboundSendDeps,
resolveOutboundSendDep,
} from "../../../src/infra/outbound/send-deps.js";
import { normalizeOutboundThreadId } from "../../../src/infra/outbound/thread-id.js";
import { normalizeMessageChannel } from "../../../src/utils/message-channel.js";
import { inspectTelegramAccount } from "./account-inspect.js";
import {
@@ -185,20 +186,6 @@ function parseTelegramExplicitTarget(raw: string) {
};
}
function normalizeOutboundThreadId(value?: string | number | null): string | undefined {
if (value == null) {
return undefined;
}
if (typeof value === "number") {
if (!Number.isFinite(value)) {
return undefined;
}
return String(Math.trunc(value));
}
const trimmed = value.trim();
return trimmed ? trimmed : undefined;
}
function buildTelegramBaseSessionKey(params: {
cfg: OpenClawConfig;
agentId: string;