fix(chat): normalize @lid JIDs to @s.whatsapp.net and include Contact table entries in fetchChats - #2703
Open
xstudioproductions wants to merge 1 commit into
Conversation
… table entries in fetchChats
Contributor
There was a problem hiding this comment.
Sorry @xstudioproductions, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
Contributor
Reviewer's GuideRefactors fetchChats to union message- and contact-based chats, normalizes @lid JIDs to @s.whatsapp.net in the API response, and adds PostgreSQL-safe type casting and defaults to ensure consistent chat rendering in the Evolution Manager UI. Flow diagram for unified chat fetching and JID normalizationflowchart TD
A[fetchChats] --> B[msg_chats CTE]
A --> C[contact_chats CTE]
B --> D[combined_chats UNION ALL]
C --> D
D --> E[Deduplicate by remoteJid]
E --> F[Normalize @lid to @s.whatsapp.net]
F --> G[Return chats to Evolution Manager]
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Description
This PR resolves an issue where personal 1-on-1 chats and contacts fail to render in the Evolution Manager UI due to WhatsApp Multi-Device
@lid(Linked Identity) JIDs and unlinked"Contact"table records.🐛 Problem
@lidJID Filtering in Frontend: WhatsApp Multi-Device assigns@liddomain JIDs (e.g.,173452640125135@lid) to incoming messages and chats. However, the Evolution Manager UI filters personal contacts strictly checking ifremoteJidends with@s.whatsapp.net. As a result, all@lidpersonal chats are hidden from theContatostab in the UI.fetchChatspreviously queried solely from the"Message"table. Contacts saved in the"Contact"table without message history were excluded from the chat sidebar.🛠️ Solution
src/api/services/channel.service.ts(fetchChats) to format@lidsuffixes to@s.whatsapp.netin the API output payload, ensuring full compatibility with Evolution Manager UI.fetchChatsSQL query into Common Table Expressions (msg_chats&contact_chats) joined byUNION ALLto include both active message threads and saved address book contacts.NULL::jsonb,NULL::text,NULL::integer) to ensure schema compatibility across PostgreSQL database instances.🧪 How Has This Been Tested?
POST /chat/findChats/:instanceNamereturns all 1-on-1 personal contacts with@s.whatsapp.netJIDs.@g.us), push names, profile pictures, and last message previews are displayed and selectable.Summary by Sourcery
Ensure personal chats and saved contacts are consistently returned and displayed by normalizing JIDs and expanding chat retrieval beyond message history.
Bug Fixes:
Enhancements: