From b69ecc004dc9a96e77e264ecb3af52ad31c01d65 Mon Sep 17 00:00:00 2001 From: Renato Alcara Date: Sat, 25 Apr 2026 12:33:31 -0300 Subject: [PATCH] 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) --- src/Socket/messages-recv.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Socket/messages-recv.ts b/src/Socket/messages-recv.ts index 1f6f909c..53723194 100644 --- a/src/Socket/messages-recv.ts +++ b/src/Socket/messages-recv.ts @@ -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') } })