Revert "fix(list-message): use correct biz node structure for listMessage"
This commit is contained in:
@@ -628,12 +628,8 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
|||||||
} else if (message.templateMessage) {
|
} else if (message.templateMessage) {
|
||||||
return 'template'
|
return 'template'
|
||||||
} else if (message.listMessage) {
|
} else if (message.listMessage) {
|
||||||
(SINGLE_SELECT and PRODUCT_LIST) need biz > list node
|
|
||||||
return 'list'
|
|
||||||
|
|
||||||
// listMessage works natively without biz node
|
// listMessage works natively without biz node
|
||||||
return undefined
|
return undefined
|
||||||
|
|
||||||
} else if (message.buttonsResponseMessage) {
|
} else if (message.buttonsResponseMessage) {
|
||||||
return 'buttons_response'
|
return 'buttons_response'
|
||||||
} else if (message.listResponseMessage) {
|
} else if (message.listResponseMessage) {
|
||||||
@@ -675,13 +671,8 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
|||||||
} else if (innerMessage.templateMessage) {
|
} else if (innerMessage.templateMessage) {
|
||||||
return 'template'
|
return 'template'
|
||||||
} else if (innerMessage.listMessage) {
|
} else if (innerMessage.listMessage) {
|
||||||
|
|
||||||
// All listMessages (SINGLE_SELECT and PRODUCT_LIST) need biz > list node
|
|
||||||
return 'list'
|
|
||||||
|
|
||||||
// listMessage works natively without biz node
|
// listMessage works natively without biz node
|
||||||
return undefined
|
return undefined
|
||||||
|
|
||||||
} else if (innerMessage.buttonsResponseMessage) {
|
} else if (innerMessage.buttonsResponseMessage) {
|
||||||
return 'buttons_response'
|
return 'buttons_response'
|
||||||
} else if (innerMessage.listResponseMessage) {
|
} else if (innerMessage.listResponseMessage) {
|
||||||
@@ -1208,13 +1199,6 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
|||||||
'[DEBUG] Interactive message structure'
|
'[DEBUG] Interactive message structure'
|
||||||
)
|
)
|
||||||
|
|
||||||
// Log message check for biz node (similar to Pastorini)
|
|
||||||
const messageKeys = Object.keys(message).filter(k => (message as any)[k] != null)
|
|
||||||
logger.info(
|
|
||||||
{ hasInteractive: !!interactiveMsg, messageKeys },
|
|
||||||
'[BIZ NODE] Checking message for biz node...'
|
|
||||||
)
|
|
||||||
|
|
||||||
logger.warn(
|
logger.warn(
|
||||||
{ msgId, buttonType, to: destinationJid, enableInteractiveMessages, isCatalog },
|
{ msgId, buttonType, to: destinationJid, enableInteractiveMessages, isCatalog },
|
||||||
'[EXPERIMENTAL] Injecting biz node for interactive message - may cause ban'
|
'[EXPERIMENTAL] Injecting biz node for interactive message - may cause ban'
|
||||||
@@ -1224,20 +1208,9 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
|||||||
metrics.interactiveMessagesSent.inc({ type: buttonType })
|
metrics.interactiveMessagesSent.inc({ type: buttonType })
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// Differentiate biz node structure based on message type
|
|
||||||
// isListMessage: true for direct listMessage OR nativeFlowMessage with single_select
|
|
||||||
const isListMessage = buttonType === 'list' || isListNativeFlow(message)
|
|
||||||
|
|
||||||
if (isListMessage) {
|
|
||||||
// For listMessage: use biz > list (type=product_list, v=2)
|
|
||||||
// This is the format that works on both phone and web WhatsApp
|
|
||||||
// Reference: Pastorini implementation
|
|
||||||
=======
|
|
||||||
// For listMessage (legacy format), use direct <list> tag
|
// For listMessage (legacy format), use direct <list> tag
|
||||||
// This matches pastorini's working implementation
|
// This matches pastorini's working implementation
|
||||||
if (buttonType === 'list') {
|
if (buttonType === 'list') {
|
||||||
|
|
||||||
;(stanza.content as BinaryNode[]).push({
|
;(stanza.content as BinaryNode[]).push({
|
||||||
tag: 'biz',
|
tag: 'biz',
|
||||||
attrs: {},
|
attrs: {},
|
||||||
@@ -1253,13 +1226,6 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
|||||||
})
|
})
|
||||||
logger.info(
|
logger.info(
|
||||||
{ msgId, to: destinationJid },
|
{ msgId, to: destinationJid },
|
||||||
|
|
||||||
'[BIZ NODE] Added list biz node (type=product_list, v=2) for listMessage'
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
// For other interactive messages (native_flow, buttons, templates, carousels):
|
|
||||||
// use biz > interactive > native_flow
|
|
||||||
=======
|
|
||||||
'[EXPERIMENTAL] Injected biz node for listMessage (legacy format)'
|
'[EXPERIMENTAL] Injected biz node for listMessage (legacy format)'
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
@@ -1292,8 +1258,8 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
|||||||
|
|
||||||
// For private 1:1 chats, add bot node (required for some interactive messages to render)
|
// For private 1:1 chats, add bot node (required for some interactive messages to render)
|
||||||
// Only inject for actual user JIDs, not broadcasts, newsletters, or Meta AI bots
|
// Only inject for actual user JIDs, not broadcasts, newsletters, or Meta AI bots
|
||||||
// IMPORTANT: Carousels, catalog messages, and list messages should NOT have bot node
|
// IMPORTANT: Carousels and catalog messages should NOT have bot node
|
||||||
// List messages use biz > list structure and don't need bot node
|
// as they are regular interactive messages, not bot messages
|
||||||
// NOTE: Only for regular JIDs, NOT hosted JIDs (to avoid interference with interactive messages)
|
// NOTE: Only for regular JIDs, NOT hosted JIDs (to avoid interference with interactive messages)
|
||||||
const isPrivateUserChat = (
|
const isPrivateUserChat = (
|
||||||
isPnUser(destinationJid) ||
|
isPnUser(destinationJid) ||
|
||||||
@@ -1301,7 +1267,7 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
|||||||
destinationJid?.endsWith('@c.us')
|
destinationJid?.endsWith('@c.us')
|
||||||
) && !isJidBot(destinationJid)
|
) && !isJidBot(destinationJid)
|
||||||
|
|
||||||
if (isPrivateUserChat && !isCarousel && !isCatalog && !isListMessage) {
|
if (isPrivateUserChat && !isCarousel && !isCatalog) {
|
||||||
;(stanza.content as BinaryNode[]).push({
|
;(stanza.content as BinaryNode[]).push({
|
||||||
tag: 'bot',
|
tag: 'bot',
|
||||||
attrs: { biz_bot: '1' }
|
attrs: { biz_bot: '1' }
|
||||||
@@ -1320,11 +1286,6 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
|||||||
{ msgId, to: destinationJid, buttonType },
|
{ msgId, to: destinationJid, buttonType },
|
||||||
'[EXPERIMENTAL] Skipping bot node for catalog message (with biz node)'
|
'[EXPERIMENTAL] Skipping bot node for catalog message (with biz node)'
|
||||||
)
|
)
|
||||||
} else if (isListMessage) {
|
|
||||||
logger.debug(
|
|
||||||
{ msgId, to: destinationJid, buttonType },
|
|
||||||
'[BIZ NODE] Skipping bot node for list message (uses list biz node)'
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Track success and latency after message is sent
|
// Track success and latency after message is sent
|
||||||
@@ -1413,10 +1374,6 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
|||||||
;(stanza.content as BinaryNode[]).push(...additionalNodes)
|
;(stanza.content as BinaryNode[]).push(...additionalNodes)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log stanza content tags for debugging (similar to Pastorini format)
|
|
||||||
const contentTags = (stanza.content as BinaryNode[]).map((n: BinaryNode) => n.tag)
|
|
||||||
logger.info({ msgId, contentTags }, `[STANZA] Content tags: ${JSON.stringify(contentTags)}`)
|
|
||||||
|
|
||||||
logger.debug({ msgId }, `sending message to ${participants.length} devices`)
|
logger.debug({ msgId }, `sending message to ${participants.length} devices`)
|
||||||
|
|
||||||
await sendNode(stanza)
|
await sendNode(stanza)
|
||||||
|
|||||||
Reference in New Issue
Block a user