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:
@@ -51,6 +51,7 @@ import {
|
|||||||
getBinaryNodeChildren,
|
getBinaryNodeChildren,
|
||||||
isHostedLidUser,
|
isHostedLidUser,
|
||||||
isHostedPnUser,
|
isHostedPnUser,
|
||||||
|
isJidBot,
|
||||||
isJidGroup,
|
isJidGroup,
|
||||||
isLidUser,
|
isLidUser,
|
||||||
isPnUser,
|
isPnUser,
|
||||||
@@ -1096,8 +1097,15 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
|||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
// For private chats, add bot node (required for interactive messages to render)
|
// For private 1:1 chats, add bot node (required for interactive messages to render)
|
||||||
if (!isJidGroup(destinationJid)) {
|
// 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({
|
;(stanza.content as BinaryNode[]).push({
|
||||||
tag: 'bot',
|
tag: 'bot',
|
||||||
attrs: { biz_bot: '1' }
|
attrs: { biz_bot: '1' }
|
||||||
|
|||||||
Reference in New Issue
Block a user