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 <noreply@anthropic.com>
This commit is contained in:
Renato Alcara
2026-01-26 11:49:12 -03:00
parent 2b4685944a
commit d66fd14775
+10 -2
View File
@@ -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' }