Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/core/engines/gows/session.gows.core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2350,7 +2350,23 @@ export class WhatsappSessionGoWSCore extends WhatsappSession {

protected async fetchChatSummary(chat, merge: boolean): Promise<ChatSummary> {
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 lastMessageQuery: GetChatMessagesQuery = {
limit: 1,
Expand Down
16 changes: 14 additions & 2 deletions src/core/engines/webjs/session.webjs.core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1855,14 +1855,26 @@ export class WhatsappSessionWebJSCore extends WhatsappSession {

@Activity()
public async getPresence(id: string): Promise<WAHAChatPresences> {
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<any> {
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);
}

Expand Down