Repository navigation
fix(store): resolve LID JIDs to phone JIDs for unified message history - #16
Merged
Merged
Conversation
WhatsApp is migrating contacts from phone-based JIDs (@s.whatsapp.net) to LID-based JIDs (@lid). Messages arriving under the new LID format were stored separately and invisible when querying by phone JID. Add a LIDResolver that reads whatsmeow's whatsmeow_lid_map table to transparently map between LID and phone JIDs. Applied on both the storage path (normalize to phone JID) and query path (match both JIDs for already-stored LID messages). Fixes vicentereig#15 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
Fixes #15 — messages from contacts whose WhatsApp sessions have migrated to the new LID (Linked Identity) format are invisible in
messages list.LIDResolverthat reads whatsmeow'swhatsmeow_lid_maptable to transparently map between@lidand@s.whatsapp.netJIDsStoreChat,StoreMessage): normalize@lidJIDs to@s.whatsapp.netso all messages for a contact live under one canonical JIDListMessages): when filtering by phone JID, also match the corresponding@lidJID (for messages already stored pre-fix)NewAppusing the existingwhatsapp.dbBackground
WhatsApp is actively migrating contacts from phone-based JIDs to LID-based JIDs as a privacy initiative. The whatsmeow library already maintains the PN↔LID mapping in
whatsmeow_lid_map, but whatsapp-cli was not consulting it. This caused the same contact to appear as two separate chats with newer messages invisible to queries by phone number.Design decisions
whatsapp.db(mode=ro) — the resolver never writes to whatsmeow's databasewhatsapp.dbis unavailable, behavior is unchangedListMessagesmatches both JID variants to surface messages stored under either format, handling both pre-fix and post-fix dataTest plan
go test ./...)messages list --chat <phone>@s.whatsapp.netnow returns messages stored under both the phone JID and the LID JID@lidJID directly — should resolve to phone JID and return all messages🤖 Generated with Claude Code