fix(NOWEB): fix update contact - mention #2285

This commit is contained in:
devlikepro committed 2026-10-02 13:07:08 +07:00
1 parent ce1e42bb17
commit 235ec01d8b
1 file changed
+18 -7
+18 -7
View File
@@ -2016,6 +2016,7 @@ export class WhatsappSessionNoWebCore extends WhatsappSession {
@Activity()
public async upsertContact(chatId: string, body: ContactUpdateBody) {
const jid = await this.hooks.wid.chat.promise(chatId, 'upsertContact');
const lid = await this.resolveContactLid(jid);
let fullName = body.firstName;
if (body.lastName) {
fullName = `${body.firstName} ${body.lastName}`;
@@ -2023,16 +2024,26 @@ export class WhatsappSessionNoWebCore extends WhatsappSession {
const action = {
fullName: fullName,
firstName: body.firstName,
lidJid: lid ?? undefined,
saveOnPrimaryAddressbook: true,
};
await this.sock.addOrEditContact(jid, action);
const updates: Partial<Contact>[] = [
{
id: jid,
name: fullName,
},
];
this.sock.ev.emit('contacts.update', updates);
const update: Partial<Contact> = {
id: jid,
name: fullName,
};
if (lid) {
update.lid = lid;
}
this.sock.ev.emit('contacts.update', [update]);
}
private async resolveContactLid(pn: string): Promise<string | null> {
const lid = await this.sock.signalRepository.lidMapping.getLIDForPN(pn);
if (!lid) {
return null;
}
return jidNormalizedUser(lid);
}
async getContact(query: ContactQuery) {