Skip to content

Commit 6275b10

Browse files
rootclaude
authored andcommitted
fix: extend LID resolution to message-receipt.update and contacts handlers
- message-receipt.update: resolve @lid to @s.whatsapp.net before updating read status, ensuring receipts match messages stored with resolved JIDs - contacts.upsert: use lidJidAlt when contact.id contains @lid, so contacts are saved with the correct @s.whatsapp.net JID - contacts.update: same LID resolution for contact updates Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 11ae4d1 commit 6275b10

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,9 @@ export class BaileysStartupService extends ChannelStartupService {
782782
'contacts.upsert': async (contacts: Contact[]) => {
783783
try {
784784
const contactsRaw: any = contacts.map((contact) => ({
785-
remoteJid: contact.id,
785+
remoteJid: contact.id.includes('@lid') && (contact as any)?.lidJidAlt
786+
? (contact as any).lidJidAlt
787+
: contact.id,
786788
pushName: contact?.name || contact?.verifiedName || contact.id.split('@')[0],
787789
profilePicUrl: null,
788790
instanceId: this.instanceId,
@@ -821,7 +823,9 @@ export class BaileysStartupService extends ChannelStartupService {
821823

822824
const updatedContacts = await Promise.all(
823825
contacts.map(async (contact) => ({
824-
remoteJid: contact.id,
826+
remoteJid: contact.id.includes('@lid') && (contact as any)?.lidJidAlt
827+
? (contact as any).lidJidAlt
828+
: contact.id,
825829
pushName: contact?.name || contact?.verifiedName || contact.id.split('@')[0],
826830
profilePicUrl: (await this.profilePicture(contact.id)).profilePictureUrl,
827831
instanceId: this.instanceId,
@@ -1671,7 +1675,11 @@ export class BaileysStartupService extends ChannelStartupService {
16711675

16721676
for (const event of payload) {
16731677
if (typeof event.key.remoteJid === 'string' && typeof event.receipt.readTimestamp === 'number') {
1674-
remotesJidMap[event.key.remoteJid] = event.receipt.readTimestamp;
1678+
// Resolve @lid to @s.whatsapp.net so read receipts match stored messages
1679+
const jid = event.key.remoteJid.includes('@lid') && (event.key as any)?.remoteJidAlt
1680+
? (event.key as any).remoteJidAlt
1681+
: event.key.remoteJid;
1682+
remotesJidMap[jid] = event.receipt.readTimestamp;
16751683
}
16761684
}
16771685

0 commit comments

Comments
 (0)