From d66fd1477570a85a73567c6b3f1ee577e8d32ef8 Mon Sep 17 00:00:00 2001 From: Renato Alcara Date: Mon, 26 Jan 2026 11:49:12 -0300 Subject: [PATCH] fix(messages): use precise check for private chats when injecting bot node The previous condition `!isJidGroup()` was too broad and would incorrectly inject bot nodes for status broadcasts, newsletters, and Meta AI bots. Now uses explicit checks for private 1:1 user conversations: - isPnUser() for @s.whatsapp.net JIDs - isLidUser() for @lid JIDs - @c.us suffix for legacy format - Excludes bot JIDs with isJidBot() This prevents potential issues with message delivery to non-user destinations. Co-Authored-By: Claude Opus 4.5 --- src/Socket/messages-send.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Socket/messages-send.ts b/src/Socket/messages-send.ts index aa9f2660..b06eefb5 100644 --- a/src/Socket/messages-send.ts +++ b/src/Socket/messages-send.ts @@ -51,6 +51,7 @@ import { getBinaryNodeChildren, isHostedLidUser, isHostedPnUser, + isJidBot, isJidGroup, isLidUser, isPnUser, @@ -1096,8 +1097,15 @@ export const makeMessagesSocket = (config: SocketConfig) => { ] }) - // For private chats, add bot node (required for interactive messages to render) - if (!isJidGroup(destinationJid)) { + // For private 1:1 chats, add bot node (required for interactive messages to render) + // Only inject for actual user JIDs, not broadcasts, newsletters, or Meta AI bots + const isPrivateUserChat = ( + isPnUser(destinationJid) || + isLidUser(destinationJid) || + destinationJid?.endsWith('@c.us') + ) && !isJidBot(destinationJid) + + if (isPrivateUserChat) { ;(stanza.content as BinaryNode[]).push({ tag: 'bot', attrs: { biz_bot: '1' }