fix(carousel): viewOnceMessage wrapper sem messageContextInfo + estrutura Pastorini

Mudanças baseadas na comparação com Pastorini:

1. Adicionado viewOnceMessage wrapper MÍNIMO (sem messageContextInfo)
   - viewOnceMessage é obrigatório para Web/Desktop renderizar carousel
   - messageContextInfo pode ter causado o erro 479 anterior

2. Removido campos extras que Pastorini não usa:
   - Removido messageParamsJson dos cards
   - Removido messageVersion dos cards
   - Removido carouselCardType (Pastorini não define)
   - Removido header vazio no nível raiz (Pastorini não envia)

3. Estrutura final:
   viewOnceMessage.message.interactiveMessage.carouselMessage

https://claude.ai/code/session_01EK9NpViRCtda1WAvFd8ptR
This commit is contained in:
Claude
2026-02-06 17:21:34 +00:00
parent 0c39339e00
commit 1ebf95b5d6
+13 -17
View File
@@ -636,34 +636,30 @@ export const generateCarouselMessage = async (
body: { text: card.body || '' },
footer: card.footer ? { text: card.footer } : undefined,
nativeFlowMessage: {
buttons: card.buttons.map(formatNativeFlowButton),
messageParamsJson: JSON.stringify({}),
messageVersion: 1
buttons: card.buttons.map(formatNativeFlowButton)
}
}
}))
// Build the interactive message with carousel
// Build the interactive message with carousel (matching Pastorini structure)
const interactiveMessage: proto.Message.IInteractiveMessage = {
body: { text: text || '' },
footer: footer ? { text: footer } : undefined,
header: {
title: '',
subtitle: '',
hasMediaAttachment: false
},
carouselMessage: {
cards: carouselCards,
messageVersion: 1,
carouselCardType: 1 // HSCROLL_CARDS - required for Web/Desktop to render carousel cards
messageVersion: 1
}
}
// Return as direct interactiveMessage (no viewOnceMessage wrapper)
// viewOnceMessage causes error 479 rejection from linked devices (Web/Desktop)
// carouselCardType: 1 (HSCROLL_CARDS) tells Web how to render the cards
// Wrap in viewOnceMessage for WhatsApp Web/Desktop compatibility
// Without this wrapper, Web only renders header/body text
// Note: using minimal wrapper (no messageContextInfo) to avoid error 479
return {
interactiveMessage
viewOnceMessage: {
message: {
interactiveMessage
}
}
}
}
@@ -1160,8 +1156,8 @@ export const generateWAMessageContent = async (
}
// Pass options for media processing if cards have images/videos
const generated = await generateCarouselMessage(carouselOptions, options)
m.interactiveMessage = generated.interactiveMessage
options.logger?.info('Sending carouselMessage with carouselCardType HSCROLL_CARDS')
m.viewOnceMessage = generated.viewOnceMessage
options.logger?.info('Sending carouselMessage with viewOnceMessage wrapper (no messageContextInfo)')
}
// Check for nativeList
else if (hasNonNullishProperty(message, 'nativeList')) {