fix: canonicalize sync media enqueue JIDs#244
Merged
Conversation
Live sync can receive one-to-one chats as @lid JIDs while message storage canonicalizes them to phone-number JIDs. Queue media downloads with the same canonical chat JID used for storage so the worker can find the just-stored row and mark local_path after downloading. Add regression coverage for a live @lid media message resolving to a PN chat row. Assisted-by: ChatGPT:gpt-5
dinakars777
added a commit
that referenced
this pull request
May 16, 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.
fix: canonicalize sync media enqueue JIDs
Summary
Fixes background media downloads during
sync --follow --download-mediawhen live one-to-one messages arrive with an@lidchat JID.Message storage canonicalizes incoming chat JIDs via
canonicalStoreJID, so the DB row may be stored under the resolved phone-number JID (@s.whatsapp.net). The media download enqueue path previously used the raw livepm.Chat.String(), which could still be an@lid. The media worker then looked up the wrong(chat_jid, msg_id)and skipped the download because the row was not found.This change queues media downloads using the same canonical chat JID used by message storage.
Test
Added regression coverage for a live
@lidmedia message that resolves to a PN chat row. Pre-fix, the row is stored under the PN JID but the worker looks up the LID JID, leavinglocal_pathempty. Post-fix, the media is downloaded andlocal_pathis set.go test ./internal/app -run TestSyncDownloadMediaCanonicalizesLIDChatBeforeEnqueue -count=1Optional pre-fix failure check:
Notes
Observed with
sync --follow --download-media: live image messages were stored with media metadata, butlocal_pathstayed empty. Manualmedia download --chat <pn-jid> --id <msg-id>worked immediately, confirming the metadata/download path was valid and the issue was the live enqueue lookup JID.