From 9fcef82f2dca21bcbdcbdc3d2669d5d7945305e0 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Tue, 7 Apr 2026 06:48:20 +0100 Subject: [PATCH] refactor: dedupe bluebubbles readers --- extensions/bluebubbles/src/accounts.ts | 3 ++- extensions/bluebubbles/src/channel.ts | 15 +++++++------ extensions/bluebubbles/src/probe.ts | 3 ++- extensions/bluebubbles/src/send.ts | 12 +++++----- extensions/bluebubbles/src/setup-surface.ts | 9 ++++---- extensions/bluebubbles/src/targets.ts | 23 ++++++++++---------- extensions/bluebubbles/src/webhook-shared.ts | 3 ++- 7 files changed, 37 insertions(+), 31 deletions(-) diff --git a/extensions/bluebubbles/src/accounts.ts b/extensions/bluebubbles/src/accounts.ts index c6016117f0b..02fd967178c 100644 --- a/extensions/bluebubbles/src/accounts.ts +++ b/extensions/bluebubbles/src/accounts.ts @@ -5,6 +5,7 @@ import { } from "openclaw/plugin-sdk/account-resolution"; import { resolveChannelStreamingChunkMode } from "openclaw/plugin-sdk/channel-streaming"; import type { OpenClawConfig } from "openclaw/plugin-sdk/core"; +import { normalizeOptionalString } from "openclaw/plugin-sdk/text-runtime"; import { hasConfiguredSecretInput, normalizeSecretInputString } from "./secret-input.js"; import { normalizeBlueBubblesServerUrl, type BlueBubblesAccountConfig } from "./types.js"; @@ -58,7 +59,7 @@ export function resolveBlueBubblesAccount(params: { return { accountId, enabled: baseEnabled !== false && accountEnabled, - name: merged.name?.trim() || undefined, + name: normalizeOptionalString(merged.name), config: merged, configured, baseUrl, diff --git a/extensions/bluebubbles/src/channel.ts b/extensions/bluebubbles/src/channel.ts index 34317a8bc21..a17de0dfcf8 100644 --- a/extensions/bluebubbles/src/channel.ts +++ b/extensions/bluebubbles/src/channel.ts @@ -17,6 +17,7 @@ import { createComputedAccountStatusAdapter, createDefaultChannelRuntimeState, } from "openclaw/plugin-sdk/status-helpers"; +import { normalizeOptionalString } from "openclaw/plugin-sdk/text-runtime"; import { type ResolvedBlueBubblesAccount } from "./accounts.js"; import { bluebubblesMessageActions } from "./actions.js"; import { @@ -135,7 +136,7 @@ export const bluebubblesPlugin: ChannelPlugin", resolveTarget: async ({ normalized }) => { - const to = normalized?.trim(); + const to = normalizeOptionalString(normalized); if (!to) { return null; } @@ -160,7 +161,7 @@ export const bluebubblesPlugin: ChannelPlugin { - const trimmed = value?.trim(); + const trimmed = normalizeOptionalString(value); if (!trimmed) { return null; } @@ -196,7 +197,7 @@ export const bluebubblesPlugin: ChannelPlugin ({ - currentChannelId: context.To?.trim() || undefined, + currentChannelId: normalizeOptionalString(context.To), currentThreadTs: context.ReplyToIdFull ?? context.ReplyToId, hasRepliedRef, }), @@ -314,7 +315,7 @@ export const bluebubblesPlugin: ChannelPlugin { - const trimmed = to?.trim(); + const trimmed = normalizeOptionalString(to); if (!trimmed) { return { ok: false, @@ -328,7 +329,7 @@ export const bluebubblesPlugin: ChannelPlugin { const runtime = await loadBlueBubblesChannelRuntime(); - const rawReplyToId = typeof replyToId === "string" ? replyToId.trim() : ""; + const rawReplyToId = normalizeOptionalString(replyToId) ?? ""; const replyToMessageGuid = rawReplyToId ? runtime.resolveBlueBubblesMessageId(rawReplyToId, { requireKnownShortId: true }) : ""; diff --git a/extensions/bluebubbles/src/probe.ts b/extensions/bluebubbles/src/probe.ts index 27b0a36bdc5..5bec4c9a773 100644 --- a/extensions/bluebubbles/src/probe.ts +++ b/extensions/bluebubbles/src/probe.ts @@ -1,4 +1,5 @@ import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime"; +import { normalizeOptionalString } from "openclaw/plugin-sdk/text-runtime"; import type { BaseProbeResult } from "./runtime-api.js"; import { normalizeSecretInputString } from "./secret-input.js"; import { buildBlueBubblesApiUrl, blueBubblesFetchWithTimeout } from "./types.js"; @@ -24,7 +25,7 @@ const serverInfoCache = new Map