refactor: dedupe messaging lowercase helpers

This commit is contained in:
Peter Steinberger
2026-04-07 15:20:23 +01:00
parent d43cc470c6
commit 4bcbb22678
15 changed files with 58 additions and 45 deletions

View File

@@ -3,6 +3,7 @@ import {
stripChannelTargetPrefix,
type ChannelOutboundSessionRouteParams,
} from "openclaw/plugin-sdk/channel-core";
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/text-runtime";
export function resolveFeishuOutboundSessionRoute(params: ChannelOutboundSessionRouteParams) {
let trimmed = stripChannelTargetPrefix(params.target, "feishu", "lark");
@@ -10,7 +11,7 @@ export function resolveFeishuOutboundSessionRoute(params: ChannelOutboundSession
return null;
}
const lower = trimmed.toLowerCase();
const lower = normalizeLowercaseStringOrEmpty(trimmed);
let isGroup = false;
let typeExplicit = false;
@@ -25,7 +26,7 @@ export function resolveFeishuOutboundSessionRoute(params: ChannelOutboundSession
}
if (!typeExplicit) {
const idLower = trimmed.toLowerCase();
const idLower = normalizeLowercaseStringOrEmpty(trimmed);
if (idLower.startsWith("ou_") || idLower.startsWith("on_")) {
isGroup = false;
}

View File

@@ -1,3 +1,4 @@
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/text-runtime";
import type { FeishuIdType } from "./types.js";
const CHAT_ID_PREFIX = "oc_";
@@ -29,7 +30,7 @@ export function normalizeFeishuTarget(raw: string): string | null {
}
const withoutProvider = stripProviderPrefix(trimmed);
const lowered = withoutProvider.toLowerCase();
const lowered = normalizeLowercaseStringOrEmpty(withoutProvider);
if (lowered.startsWith("chat:")) {
return withoutProvider.slice("chat:".length).trim() || null;
}
@@ -65,7 +66,7 @@ export function formatFeishuTarget(id: string, type?: FeishuIdType): string {
export function resolveReceiveIdType(id: string): "chat_id" | "open_id" | "user_id" {
const trimmed = id.trim();
const lowered = trimmed.toLowerCase();
const lowered = normalizeLowercaseStringOrEmpty(trimmed);
if (
lowered.startsWith("chat:") ||
lowered.startsWith("group:") ||