|
4 | 4 | sendMediaWithLeadingCaption, |
5 | 5 | } from "openclaw/plugin-sdk/reply-payload"; |
6 | 6 | import { isPrivateNetworkOptInEnabled } from "openclaw/plugin-sdk/ssrf-runtime"; |
| 7 | +import { normalizeOptionalString } from "openclaw/plugin-sdk/text-runtime"; |
7 | 8 | import { downloadBlueBubblesAttachment } from "./attachments.js"; |
8 | 9 | import { markBlueBubblesChatRead, sendBlueBubblesTyping } from "./chat.js"; |
9 | 10 | import { resolveBlueBubblesConversationRoute } from "./conversation-route.js"; |
@@ -92,8 +93,7 @@ const pendingOutboundMessageIds: PendingOutboundMessageId[] = []; |
92 | 93 | let pendingOutboundMessageIdCounter = 0; |
93 | 94 |
|
94 | 95 | function trimOrUndefined(value?: string | null): string | undefined { |
95 | | - const trimmed = value?.trim(); |
96 | | - return trimmed ? trimmed : undefined; |
| 96 | + return normalizeOptionalString(value); |
97 | 97 | } |
98 | 98 |
|
99 | 99 | function normalizeSnippet(value: string): string { |
@@ -732,7 +732,7 @@ export async function processMessage( |
732 | 732 | chatId: message.chatId ?? undefined, |
733 | 733 | chatIdentifier: message.chatIdentifier ?? undefined, |
734 | 734 | }); |
735 | | - const groupName = message.chatName?.trim() || undefined; |
| 735 | + const groupName = normalizeOptionalString(message.chatName); |
736 | 736 |
|
737 | 737 | if (accessDecision.decision !== "allow") { |
738 | 738 | if (isGroup) { |
@@ -1105,11 +1105,11 @@ export async function processMessage( |
1105 | 1105 | // The sender identity is included in the envelope body via formatInboundEnvelope. |
1106 | 1106 | const senderLabel = message.senderName || `user:${message.senderId}`; |
1107 | 1107 | const fromLabel = isGroup |
1108 | | - ? `${message.chatName?.trim() || "Group"} id:${peerId}` |
| 1108 | + ? `${normalizeOptionalString(message.chatName) || "Group"} id:${peerId}` |
1109 | 1109 | : senderLabel !== message.senderId |
1110 | 1110 | ? `${senderLabel} id:${message.senderId}` |
1111 | 1111 | : senderLabel; |
1112 | | - const groupSubject = isGroup ? message.chatName?.trim() || undefined : undefined; |
| 1112 | + const groupSubject = isGroup ? normalizeOptionalString(message.chatName) : undefined; |
1113 | 1113 | const groupMembers = isGroup |
1114 | 1114 | ? formatGroupMembers({ |
1115 | 1115 | participants: message.participants, |
|
0 commit comments