mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-15 19:21:08 +00:00
refactor: dedupe messaging lowercase helpers
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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:") ||
|
||||
|
||||
Reference in New Issue
Block a user