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

@@ -26,6 +26,7 @@ import {
type OpenClawConfig,
} from "openclaw/plugin-sdk/discord";
import { 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 {
listDiscordAccountIds,
@@ -196,20 +197,6 @@ function parseDiscordExplicitTarget(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 buildDiscordBaseSessionKey(params: {
cfg: OpenClawConfig;
agentId: string;