UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

27 lines (26 loc) • 1.28 kB
import { l as normalizeOptionalString, o as normalizeLowercaseStringOrEmpty } from "./string-coerce-CCIiB4H7.mjs"; import { t as normalizeChatType } from "./chat-type-CL5nBDaO.mjs"; //#region src/channels/conversation-label.ts function extractConversationId(e) { const t = normalizeOptionalString(e); if (!t) return; const n = t.split(":").filter(Boolean); return n.length > 0 ? n[n.length - 1] : t; } function shouldAppendId(e) { return /^[0-9]+$/.test(e) || /^[^\s:@]+@[^\s:@]+$/.test(e); } function resolveConversationLabel(e) { const t = normalizeOptionalString(e.ConversationLabel); if (t) return t; const n = normalizeOptionalString(e.ThreadLabel); if (n) return n; if (normalizeChatType(e.ChatType) === "direct") return normalizeOptionalString(e.SenderName) ?? normalizeOptionalString(e.From); const r = normalizeOptionalString(e.GroupChannel) || normalizeOptionalString(e.GroupSubject) || normalizeOptionalString(e.GroupSpace) || normalizeOptionalString(e.From) || ""; if (!r) return; const i = extractConversationId(e.From); if (!i || !shouldAppendId(i) || r.includes(i) || normalizeLowercaseStringOrEmpty(r).includes(" id:") || r.startsWith("#") || r.startsWith("@")) return r; return `${r} id:${i}`; } //#endregion export { resolveConversationLabel as t };