fix: resolve contact names from address book instead of phone numbers#173
Open
FreakySurgeon wants to merge 1 commit intolharries:mainfrom
Open
fix: resolve contact names from address book instead of phone numbers#173FreakySurgeon wants to merge 1 commit intolharries:mainfrom
FreakySurgeon wants to merge 1 commit intolharries:mainfrom
Conversation
… numbers The MCP server now reads contact names from whatsmeow_contacts (synced from the phone's address book) instead of the chats table which often only contained phone numbers. Handles standard JIDs, LID-based senders (common in groups), and LID-to-phone mapping. Go bridge: GetChatName() no longer treats phone numbers as valid cached names, and a new /api/refresh-contacts endpoint backfills existing chats. Co-Authored-By: Claude Opus 4.6 <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
whatsapp.py):get_sender_name()now reads contact names from thewhatsmeow_contactstable (synced from the phone's address book) with priorityfull_name > first_name > push_name, instead of relying on thechatstable which often only contains phone numbers@s.whatsapp.netJIDs, LID-based senders (common in group messages), and LID-to-phone mapping viawhatsmeow_lid_mapmain.go):GetChatName()no longer treats phone numbers as valid cached names — it re-resolves contacts when the stored name is numericPOST /api/refresh-contactsendpoint to backfill existing chat names from the whatsmeow contact storeexclude_groupsparameter tolist_chatsMCP toolProblem
When reading messages, all contacts were displayed as phone numbers (e.g.
From: 0606060606) instead of their real names. Thechatstable inmessages.dbwas populated with phone numbers becauseGetChatName()cached the first name found (often before contacts were synced), and never updated it.Meanwhile, the real contact names from the phone's address book were available in
whatsmeow_contacts(whatsapp.db) but never used.Test plan
get_sender_name()resolves phone numbers to names from address booksearch_contacts()searches both whatsmeow contacts and chats tablelist_chats()returns resolved names for individual contacts/api/refresh-contactsbackfills existing chat names from contactsGetChatName()🤖 Generated with Claude Code