fix(bluebubbles): treat null privateApiStatus as disabled, not enabled

Bug: privateApiStatus cache expires after 10 minutes, returning null.
The check '!== false' treats null as truthy, causing 500 errors when
trying to use Private API features that aren't actually available.

Root cause: In JavaScript, null !== false evaluates to true.

Fix: Changed all checks from '!== false' to '=== true', so null (cache
expired/unknown) is treated as disabled (safe default).

Files changed:
- extensions/bluebubbles/src/send.ts (line 376)
- extensions/bluebubbles/src/monitor-processing.ts (line 423)
- extensions/bluebubbles/src/attachments.ts (lines 210, 220)

Fixes #23393
This commit is contained in:
echoVic
2026-02-22 18:12:40 +08:00
committed by Peter Steinberger
parent 812bf7c8e1
commit 888b6bc948
3 changed files with 5 additions and 5 deletions

View File

@@ -207,7 +207,7 @@ export async function sendBlueBubblesAttachment(params: {
addField("chatGuid", chatGuid);
addField("name", filename);
addField("tempGuid", `temp-${Date.now()}-${crypto.randomUUID().slice(0, 8)}`);
if (privateApiStatus !== false) {
if (privateApiStatus === true) {
addField("method", "private-api");
}
@@ -217,7 +217,7 @@ export async function sendBlueBubblesAttachment(params: {
}
const trimmedReplyTo = replyToMessageGuid?.trim();
if (trimmedReplyTo && privateApiStatus !== false) {
if (trimmedReplyTo && privateApiStatus === true) {
addField("selectedMessageGuid", trimmedReplyTo);
addField("partIndex", typeof replyToPartIndex === "number" ? String(replyToPartIndex) : "0");
}

View File

@@ -420,7 +420,7 @@ export async function processMessage(
target: WebhookTarget,
): Promise<void> {
const { account, config, runtime, core, statusSink } = target;
const privateApiEnabled = getCachedBlueBubblesPrivateApiStatus(account.accountId) !== false;
const privateApiEnabled = getCachedBlueBubblesPrivateApiStatus(account.accountId) === true;
const groupFlag = resolveGroupFlagFromChatGuid(message.chatGuid);
const isGroup = typeof groupFlag === "boolean" ? groupFlag : message.isGroup;

View File

@@ -373,7 +373,7 @@ export async function sendMessageBlueBubbles(
const wantsReplyThread = Boolean(opts.replyToMessageGuid?.trim());
const wantsEffect = Boolean(effectId);
const needsPrivateApi = wantsReplyThread || wantsEffect;
const canUsePrivateApi = needsPrivateApi && privateApiStatus !== false;
const canUsePrivateApi = needsPrivateApi && privateApiStatus === true;
if (wantsEffect && privateApiStatus === false) {
throw new Error(
"BlueBubbles send failed: reply/effect requires Private API, but it is disabled on the BlueBubbles server.",
@@ -395,7 +395,7 @@ export async function sendMessageBlueBubbles(
}
// Add message effects support
if (effectId) {
if (effectId && canUsePrivateApi) {
payload.effectId = effectId;
}