fix(carousel): remove hasSubtitle proto field + add debug logging
- Remove hasSubtitle (field 10) from Header proto definition, index.js and index.d.ts - this field was adding extra bytes to encoded protobuf that working implementations don't send, potentially causing rejection - Remove hasSubtitle from carousel card headers and root header - Add [CAROUSEL DEBUG] logging in relayMessage to dump: - Encoded message bytes as base64 (for binary comparison) - Message structure as JSON - Per-device encoded bytes with DSM flag - This enables byte-level comparison with working implementations https://claude.ai/code/session_01EK9NpViRCtda1WAvFd8ptR
This commit is contained in:
@@ -572,6 +572,26 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
}
|
||||
}
|
||||
|
||||
// Debug: log per-device carousel encoding
|
||||
const carouselInMsg = msgToEncrypt?.viewOnceMessage?.message?.interactiveMessage?.carouselMessage
|
||||
|| msgToEncrypt?.deviceSentMessage?.message?.viewOnceMessage?.message?.interactiveMessage?.carouselMessage
|
||||
if (carouselInMsg) {
|
||||
try {
|
||||
const debugBytes = proto.Message.encode(proto.Message.fromObject(msgToEncrypt)).finish()
|
||||
logger.info(
|
||||
{
|
||||
recipientJid: jid,
|
||||
isDSM: !!msgToEncrypt?.deviceSentMessage,
|
||||
encodedBase64: Buffer.from(debugBytes).toString('base64'),
|
||||
encodedLength: debugBytes.length,
|
||||
},
|
||||
'[CAROUSEL DEBUG] Per-device encoded message'
|
||||
)
|
||||
} catch (err) {
|
||||
logger.warn({ jid, error: (err as Error).message }, '[CAROUSEL DEBUG] Per-device encode failed')
|
||||
}
|
||||
}
|
||||
|
||||
const bytes = encodeWAMessage(msgToEncrypt)
|
||||
const mutexKey = jid
|
||||
|
||||
@@ -899,6 +919,28 @@ export const makeMessagesSocket = (config: SocketConfig) => {
|
||||
messageContextInfo: message.messageContextInfo
|
||||
}
|
||||
|
||||
// Debug logging for carousel messages - dump encoded bytes for binary comparison
|
||||
if (isCarouselMessage(message)) {
|
||||
try {
|
||||
const msgBytes = proto.Message.encode(proto.Message.fromObject(message)).finish()
|
||||
const meMsgBytes = proto.Message.encode(proto.Message.fromObject(meMsg)).finish()
|
||||
logger.info(
|
||||
{
|
||||
msgId,
|
||||
messageBase64: Buffer.from(msgBytes).toString('base64'),
|
||||
meMsgBase64: Buffer.from(meMsgBytes).toString('base64'),
|
||||
messageBytesLength: msgBytes.length,
|
||||
meMsgBytesLength: meMsgBytes.length,
|
||||
messageStructure: JSON.stringify(proto.Message.toObject(proto.Message.fromObject(message), { defaults: false })),
|
||||
meMsgStructure: JSON.stringify(proto.Message.toObject(proto.Message.fromObject(meMsg), { defaults: false })),
|
||||
},
|
||||
'[CAROUSEL DEBUG] Encoded message bytes for binary comparison'
|
||||
)
|
||||
} catch (err) {
|
||||
logger.warn({ msgId, error: (err as Error).message }, '[CAROUSEL DEBUG] Failed to encode for debug')
|
||||
}
|
||||
}
|
||||
|
||||
const extraAttrs: BinaryNodeAttributes = {}
|
||||
|
||||
if (participant) {
|
||||
|
||||
@@ -616,8 +616,7 @@ export const generateCarouselMessage = async (
|
||||
|
||||
const header: any = {
|
||||
title: card.title || '',
|
||||
hasMediaAttachment: hasMedia,
|
||||
hasSubtitle: !!card.title
|
||||
hasMediaAttachment: hasMedia
|
||||
}
|
||||
|
||||
// Process media if present
|
||||
@@ -643,7 +642,7 @@ export const generateCarouselMessage = async (
|
||||
|
||||
// Build the interactive message with carousel
|
||||
const interactiveMessage: proto.Message.IInteractiveMessage = {
|
||||
header: text ? { title: text, hasSubtitle: true } : undefined,
|
||||
header: text ? { title: text } : undefined,
|
||||
body: { text: text || '' },
|
||||
footer: footer ? { text: footer } : undefined,
|
||||
carouselMessage: {
|
||||
|
||||
Reference in New Issue
Block a user