From d8a0995a4ddd78fec550d0be2e1e9786507dee70 Mon Sep 17 00:00:00 2001 From: NIels Date: Sat, 28 Feb 2026 16:38:14 +0100 Subject: [PATCH 1/2] [core] Fix GOWS chats/overview missing contact name and WEBJS presence with @lid GOWS: Add contact name fallback in fetchChatSummary() - when chat.name is null, look up contact via GetContactById to resolve Name/PushName. Fixes #1910. WEBJS: Convert @lid to @c.us in getPresence() and subscribePresence() using findPNByLid() before passing to underlying client, since getCurrentPresence() only handles @c.us format correctly. Fixes #1845. Co-Authored-By: Claude Opus 4.6 --- src/core/engines/gows/session.gows.core.ts | 22 +++++++++++++++++--- src/core/engines/webjs/session.webjs.core.ts | 17 +++++++++++++-- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/core/engines/gows/session.gows.core.ts b/src/core/engines/gows/session.gows.core.ts index c8ef1088c..046944e79 100644 --- a/src/core/engines/gows/session.gows.core.ts +++ b/src/core/engines/gows/session.gows.core.ts @@ -1866,14 +1866,30 @@ export class WhatsappSessionGoWSCore extends WhatsappSession { protected async fetchChatSummary(chat): Promise { const id = toCusFormat(chat.id); - const name = chat.name; + let name = chat.name; + if (!name) { + try { + const jid = toJID(chat.id); + const request = new messages.EntityByIdRequest({ + session: this.session, + id: jid, + }); + const response = await promisify(this.client.GetContactById)(request); + const contactData = parseJson(response); + if (contactData) { + name = contactData.Name || contactData.PushName; + } + } catch (e) { + // Ignore contact lookup errors + } + } const picture = await this.getContactProfilePicture(chat.id, false); - const messages = await this.getChatMessages( + const chatMessages = await this.getChatMessages( chat.id, { limit: 1, offset: 0, downloadMedia: false }, {}, ); - const message = messages.length > 0 ? messages[0] : null; + const message = chatMessages.length > 0 ? chatMessages[0] : null; return { id: id, name: name || null, diff --git a/src/core/engines/webjs/session.webjs.core.ts b/src/core/engines/webjs/session.webjs.core.ts index 660123872..24468dfa8 100644 --- a/src/core/engines/webjs/session.webjs.core.ts +++ b/src/core/engines/webjs/session.webjs.core.ts @@ -175,6 +175,7 @@ import { WAJSPresenceChatStateType, WebJSPresence } from './types'; import { isJidGroup, isJidStatusBroadcast, + isLidUser, normalizeJid, toCusFormat, } from '@waha/core/utils/jids'; @@ -1543,14 +1544,26 @@ export class WhatsappSessionWebJSCore extends WhatsappSession { @Activity() public async getPresence(id: string): Promise { - const chatId = toCusFormat(id); + let chatId = toCusFormat(id); + if (isLidUser(chatId)) { + const pn = await this.whatsapp.findPNByLid(chatId); + if (pn) { + chatId = toCusFormat(pn); + } + } const presences = await this.whatsapp.getPresence(chatId); return this.toWahaPresences(chatId, presences); } @Activity() public async subscribePresence(id: string): Promise { - const chatId = toCusFormat(id); + let chatId = toCusFormat(id); + if (isLidUser(chatId)) { + const pn = await this.whatsapp.findPNByLid(chatId); + if (pn) { + chatId = toCusFormat(pn); + } + } await this.whatsapp.subscribePresence(chatId); } From c9fae8cd5e35c46764498b0dced9920e0c0aac60 Mon Sep 17 00:00:00 2001 From: NIels Date: Sat, 28 Feb 2026 21:10:47 +0100 Subject: [PATCH 2/2] [core] Fix GOWS chats/overview: resolve LID to phone number (@c.us format) When WhatsApp uses LID (Linked ID) format internally, the chats/overview endpoint now resolves LIDs to actual phone numbers using findPNByLid(), returning IDs in the expected @c.us format instead of @lid format. Co-Authored-By: Claude Opus 4.6 --- src/core/engines/gows/session.gows.core.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/core/engines/gows/session.gows.core.ts b/src/core/engines/gows/session.gows.core.ts index 046944e79..cc58084b4 100644 --- a/src/core/engines/gows/session.gows.core.ts +++ b/src/core/engines/gows/session.gows.core.ts @@ -45,6 +45,7 @@ import { parseMessageIdSerialized } from '@waha/core/utils/ids'; import { isJidBroadcast, isJidGroup, + isLidUser, toCusFormat, toJID, } from '@waha/core/utils/jids'; @@ -1865,7 +1866,8 @@ export class WhatsappSessionGoWSCore extends WhatsappSession { } protected async fetchChatSummary(chat): Promise { - const id = toCusFormat(chat.id); + const originalId = chat.id; + let id = toCusFormat(chat.id); let name = chat.name; if (!name) { try { @@ -1883,6 +1885,17 @@ export class WhatsappSessionGoWSCore extends WhatsappSession { // Ignore contact lookup errors } } + // Resolve LID to phone number if possible + if (isLidUser(originalId)) { + try { + const resolved = await this.findPNByLid(originalId); + if (resolved.pn) { + id = resolved.pn; + } + } catch (e) { + // Keep LID format if resolution fails + } + } const picture = await this.getContactProfilePicture(chat.id, false); const chatMessages = await this.getChatMessages( chat.id,