fix(engine): forward the original deleted message id as revokedId on message.revoked#567
Open
JibayMcs wants to merge 2 commits into
Open
fix(engine): forward the original deleted message id as revokedId on message.revoked#567JibayMcs wants to merge 2 commits into
revokedId on message.revoked#567JibayMcs wants to merge 2 commits into
Conversation
added 2 commits
July 1, 2026 11:40
The message_revoke_everyone handler only used 'after' (the revocation notification) and discarded 'before' (the original deleted message). Consumers never received the id of the message that was actually deleted and could not reconcile it in their own storage. Forward before.id as an optional 'revokedId' on the RevokedMessage payload (optional because whatsapp-web.js may not always capture the original message).
- Add `revokedId` to revoked message interface and Baileys adapter - Set `revokedId` from the protocolMessage key (mirrors `id` in Baileys) - Update baileys adapter spec to assert `revokedId` equals original message id - Add session service spec that verifies DB update uses `revokedId` (original) rather than the revocation notification id
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Use case. I use OpenWA to back a two-way synced WhatsApp inbox: messages are
persisted on my side (keyed by their WhatsApp id) and rendered in a conversation UI.
When a user deletes a message for everyone from their phone, I need that deletion to
propagate to the stored conversation — i.e. flag the corresponding row as revoked and
update the UI. The
message.revokedwebhook is exactly the signal for that... except itdoesn't carry the id of the message that was deleted, so there's nothing to match against.
Digging in, the root cause is on the whatsapp-web.js engine. whatsapp-web.js emits
message_revoke_everyone(after, before)where:afteris the revocation notification — a new, distinct message whose id hasnothing to do with the deleted one;
beforeis the original deleted message (present whenever it's in the local store).The current handler only reads
afterand emitsid: after.id._serialized. That idnever matches any stored row, so:
SessionService, the revokehandler runs
messageRepository.update({ waMessageId: message.id }, { type: 'revoked' }).Because
message.idis the notification id, it matches zero rows — the stored messageis never flagged as revoked on wwebjs.
message.revoked(like the case above) receives an id they can't map back to themessage they stored, so the deletion can't be reflected.
Baileys is not affected the same way (its revoke arrives as a
protocolMessagewhose keyalready points at the original), but the payload shape was inconsistent between the two
engines, so there was no reliable cross-engine field to match on.
Fix
Add an optional
revokedIdtoRevokedMessage: the serialized id of the originaldeleted message. Both adapters populate it, so consumers have one reliable field.
revokedId: before?.id?._serialized(undefined when the original isn't in the localstore).
idstill carries the revocation notification, unchanged.revokedId(id === revokedIdthere),so the field is always present and consistent across engines.
revokedId ?? id, so theoriginal is matched on wwebjs while Baileys behaviour is preserved.
Guidance for consumers (documented on the interface): match on
revokedId, fallingback to
id.Backwards compatibility
revokedIdis optional and purely additive;id,chatId,from,to,type,body,timestampare unchanged.revokedId ?? id.Tests
revokedIdis taken frombeforeand is distinct fromid;revokedIdisundefinedwhen whatsapp-web.js provides nobefore.revokedIdmirrors the original id (id === revokedId).revokedIdwhen present and fallsback to
id.Notes
Branch is cut from the
v0.7.17tag; the affected handler and interface are byte-identicalon
main, so it applies cleanly.It works like a charm on my docker instance 🥳
Thanks for your work on this amazing tool !