mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-27 09:21:35 +07:00
fix(bluebubbles): auto-allow private network for local serverUrl and add allowPrivateNetwork to channel schema
This commit is contained in:
@@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user