fix: canonicalize JIDs in GetAvatar, DeleteMessageEveryone and EditMessage - #163
Open
FlavioPulli wants to merge 1 commit into
Conversation
…ssage
CreateJID intentionally prefixes phone numbers with "+"
(+55...@s.whatsapp.net). Message sending tolerates it because whatsmeow
normalizes the JID during usync/device resolution, and the raw-node
paths (typing, receipts, reactions) already strip it via
utils.CanonicalJID — but three paths still use the prefixed JID as-is:
- GetAvatar: GetProfilePictureInfo runs a usync IQ against the JID,
querying a nonexistent "+..." user and timing out after ~75s
("info query timed out") instead of returning the picture.
- DeleteMessageEveryone / EditMessage: the JID lands inside the
protocolMessage Key of the revoke/edit, so receiving devices look up
a chat named "+..." that doesn't exist and silently ignore the
operation.
Apply utils.CanonicalJID right after ParseJID in all three, matching
what the send/receipt paths already do. No-op for group and @lid JIDs
(their CreateJID paths never add the prefix).
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR ensures phone-number-based JIDs are canonicalized (leading '+' stripped) before use in avatar lookup and message revoke/edit flows, by introducing a small CanonicalJID helper and applying it in the relevant service methods. Sequence diagram for canonicalized JID in GetAvatar flowsequenceDiagram
actor ClientApp
participant UserService as userService
participant Utils as utils
participant WhatsAppClient as client
ClientApp->>UserService: GetAvatar(data, instance)
UserService->>UserService: ParseJID(data.Phone)
UserService->>Utils: CanonicalJID(jid)
Utils-->>UserService: canonicalJID
UserService->>WhatsAppClient: GetProfilePictureInfo(canonicalJID, data.Preview)
WhatsAppClient-->>UserService: ProfilePictureInfo
UserService-->>ClientApp: Avatar response
Sequence diagram for canonicalized JID in DeleteMessageEveryone/EditMessage flowssequenceDiagram
actor ClientApp
participant MessageService as messageService
participant Utils as utils
participant WhatsAppClient as client
ClientApp->>MessageService: DeleteMessageEveryone(data, instance)
MessageService->>MessageService: ParseJID(data.Phone)
MessageService->>Utils: CanonicalJID(recipient)
Utils-->>MessageService: canonicalRecipient
MessageService->>WhatsAppClient: SendMessage(protocolMessage with canonicalRecipient)
WhatsAppClient-->>MessageService: revoke response
ClientApp->>MessageService: EditMessage(data, instance)
MessageService->>MessageService: ParseJID(data.Phone)
MessageService->>Utils: CanonicalJID(recipient)
Utils-->>MessageService: canonicalRecipient
MessageService->>WhatsAppClient: SendMessage(protocolMessage with canonicalRecipient)
WhatsAppClient-->>MessageService: edit response
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
This was referenced Aug 4, 2026
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.
CreateJIDintentionally prefixes phone numbers with+(+55...@s.whatsapp.net). Message sending tolerates it because whatsmeow normalizes the JID during usync/device resolution, and the raw-node paths (typing, receipts, reactions) already strip it viautils.CanonicalJID— but three paths still use the prefixed JID as-is:GetProfilePictureInforuns a usync IQ against the JID, querying a nonexistent+...user and timing out after ~75s (info query timed out) instead of returning the picture.protocolMessageKey of the revoke/edit, so receiving devices look up a chat named+...that doesn't exist and silently ignore the operation.Apply
utils.CanonicalJIDright afterParseJIDin all three, matching what the send/receipt paths already do. No-op for group and@lidJIDs (theirCreateJIDpaths never add the prefix).Retargeted to
develop(replaces #130), as requested by @iagocotta in #128 (comment).Note that
mainanddevelophave no common ancestor — the GitHub API refuses to compare them (No common ancestor between main and develop) — so the base branch of the original PR could not simply be edited. This branch was created fromdevelopand the commit cherry-picked onto it.utils.CanonicalJIDdoes not exist ondevelop(it is only onmain), so the 3-line helper is included in this PR.Verified on this branch:
go build ./...andgo vet ./...both pass.Summary by Sourcery
Canonicalize JIDs in user and message operations to ensure WhatsApp lookups and protocol messages target the correct chats.
Bug Fixes:
Enhancements: