fix(bluebubbles): auto-allow private network for local serverUrl and add allowPrivateNetwork to channel schema

This commit is contained in:
Tyler Yust
2026-03-26 04:54:57 -07:00
parent c5415a474b
commit e43600c9e5
2 changed files with 13 additions and 1 deletions

View File

@@ -1,6 +1,8 @@
import { isBlockedHostnameOrIp } from "openclaw/plugin-sdk/infra-runtime";
import { resolveBlueBubblesAccount } from "./accounts.js";
import type { OpenClawConfig } from "./runtime-api.js";
import { normalizeResolvedSecretInputString } from "./secret-input.js";
import { normalizeBlueBubblesServerUrl } from "./types.js";
export type BlueBubblesAccountResolveOpts = {
serverUrl?: string;
@@ -43,10 +45,19 @@ export function resolveBlueBubblesServerAccount(params: BlueBubblesAccountResolv
if (!password) {
throw new Error("BlueBubbles password is required");
}
let autoAllowPrivateNetwork = false;
try {
const hostname = new URL(normalizeBlueBubblesServerUrl(baseUrl)).hostname.trim();
autoAllowPrivateNetwork = Boolean(hostname) && isBlockedHostnameOrIp(hostname);
} catch {
autoAllowPrivateNetwork = false;
}
return {
baseUrl,
password,
accountId: account.accountId,
allowPrivateNetwork: account.config.allowPrivateNetwork === true,
allowPrivateNetwork: account.config.allowPrivateNetwork === true || autoAllowPrivateNetwork,
};
}

View File

@@ -1409,6 +1409,7 @@ export const BlueBubblesAccountSchemaBase = z
mediaMaxMb: z.number().int().positive().optional(),
mediaLocalRoots: z.array(z.string()).optional(),
sendReadReceipts: z.boolean().optional(),
allowPrivateNetwork: z.boolean().optional(),
blockStreaming: z.boolean().optional(),
blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(),
groups: z.record(z.string(), BlueBubblesGroupConfigSchema.optional()).optional(),