fix(messages-recv): preserve custom WAMessageKey fields after proto roundtrip

proto.WebMessageInfo.fromObject() rebuilds the key from proto.MessageKey
schema, which only declares remoteJid/fromMe/id/participant. Custom
Baileys extensions (participantAlt, participantUsername, addressingMode)
are silently dropped, so process-message.ts cannot read them downstream
and authorUsername/authorPn are lost on group-participants.update,
groups.update, and group.join-request events that originate from
notifications.

Re-attach msg.key after the roundtrip to preserve the custom fields.
Addresses Codex P2 review comment on PR #382.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Renato Alcara
2026-04-25 12:33:31 -03:00
parent 5351dce3a5
commit b69ecc004d
+4
View File
@@ -2232,6 +2232,10 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
msg.messageTimestamp = +node.attrs.t!
const fullMsg = proto.WebMessageInfo.fromObject(msg) as WAMessage
// Preserve custom WAMessageKey fields (participantAlt, participantUsername,
// addressingMode) that proto.WebMessageInfo.fromObject strips because
// they aren't part of the proto.MessageKey schema.
fullMsg.key = msg.key
await upsertMessage(fullMsg, 'append')
}
})