fix(baileys): fold neutral @c.us participant ids to engine dialect for group ops#378
Merged
Merged
Conversation
…r group ops Group-participant operations (add/remove/promote/demote and createGroup) passed the caller-supplied participant ids straight to Baileys. A neutral `<phone>@c.us` id encodes on the wire as an unknown 4-byte `c.us` server suffix instead of the single-byte `s.whatsapp.net` protocol token, so these ops broke the engine's neutral-id round-trip invariant. (1:1 sends are unaffected because relayMessage re-derives the destination from the user part.) Fold participant ids back to the engine dialect via the existing `toEngineJid` transform before the groupParticipantsUpdate/groupCreate calls. `@lid` (a first-class addressing mode) and the `@g.us` group id are left untouched; the returned group info stays neutral (re-canonicalized from the response metadata), so the display contract is unchanged.
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.
What
The engine boundary uses a neutral JID dialect (
<phone>@c.us,<id>@g.us,<lid>@lid). The Baileys group-participant operations —addParticipants/removeParticipants/promoteParticipants/demoteParticipantsandcreateGroup— passed the caller-supplied participant ids straight togroupParticipantsUpdate/groupCreate. A neutral<phone>@c.usid is then placed raw on the binary wire as an unknownc.usserver suffix, instead of the single-bytes.whatsapp.netprotocol token. This broke the engine's neutral-id round-trip invariant for group ops.(1:1 messaging is unaffected — Baileys'
relayMessagere-derives the destination from the decoded user part.)Change
Fold participant ids back to the engine dialect via the existing
toEngineJidtransform (now reused at the adapter boundary through a smalltoEngineParticipantshelper) before the group calls.@lid(a first-class addressing mode) and the@g.usgroup id are left untouched.Preserved behaviour
@s.whatsapp.netparticipant id (the previous shape) is idempotent through the transform.getGroupInfo/getGroupsstill return neutral@c.usparticipant ids — the displayed ids are re-canonicalized from Baileys' response metadata, independent of the outbound wire dialect.@c.usis its correct native dialect).Tests
New
baileys.adapter.spec.tscases assert that@c.usparticipants reach the socket as@s.whatsapp.netacross all four ops andcreateGroup, while@lidpasses through unchanged. Backendlint+build+ fulljestgreen.