fix(revoke): use protocolMessageKey for original message ID#201696
fix(revoke): use protocolMessageKey for original message ID#201696Adi1231234 wants to merge 7 commits intowwebjs:mainfrom
Conversation
read the original message key directly from protocolMessageKey instead of relying on the broken last_message cache that often failed to match.
|
Hi @2hoch1, I've re-submitted with the proper PR template this time. Let me know if everything looks good now! |
|
@Adi1231234 Thanks for this PR! I've been hitting this issue for a long time - I tested it recently and it works great. |
|
I just tried this fix on my side, and it solved the issue for me, really appreciate it |
Cherry-picked from wwebjs#201696: - Use msg.protocolMessageKey directly to identify revoked message - Filter change:type event to only fire on revoked type - Removes last_message tracking heuristic PR 201698 (getContacts) skipped: our existing implementation already properly resolves promises and attaches businessProfile. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Hi @BenyFilho, Hope you're doing well. I wanted to check in on the recent PRs I opened. I understand some of them are fairly large, so they may take more time to review. I hope this isn’t a disturbance - I was wondering if I might have missed something or overlooked a step, which might be why they haven’t been merged yet. |
Description
When a message is revoked (deleted for everyone), WWJS reports the wrong message ID. The old code used a
last_messagevariable to cache the most recent message, then compared it when a revoke came in. This was unreliable because the IDs don't match after revoke, and a single variable can only track one message at a time.WhatsApp stores the original message key on the revoked model as
protocolMessageKey. This PR reads it directly instead of guessing from a cache.Changes:
msg.protocolMessageKeyto get the original IDnew Message(this, { ...msg, id: originalKey })last_messagecacheVerified from WhatsApp's bundle source code that every revoke goes through a single code path that always sets
protocolMessageKeyto the original key. It's stored as a persistent property on the model, so it survives serialization.Testing Summary
Test Details
Ran a version with verification logs in production across multiple accounts for 3 weeks. 500 revoke events analyzed -
protocolMessageKeywas present and correct in 100% of cases. No edge cases or failures observed.Environment
Type of Change
Checklist
npm test).index.d.ts) have been updated if necessary.example.js) / documentation have been updated if applicable.