From 1890b6a021a4118e68c9588399f64c9d4103c9c2 Mon Sep 17 00:00:00 2001 From: Adhiraj Singh Date: Mon, 27 Sep 2021 16:55:42 +0530 Subject: [PATCH] fix contact update --- src/Socket/messages-recv.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Socket/messages-recv.ts b/src/Socket/messages-recv.ts index cde2da9..e651ae1 100644 --- a/src/Socket/messages-recv.ts +++ b/src/Socket/messages-recv.ts @@ -2,7 +2,7 @@ import { makeGroupsSocket } from "./groups" import { SocketConfig, WAMessageStubType, ParticipantAction, Chat, GroupMetadata } from "../Types" import { decodeMessageStanza, encodeBigEndian, toNumber } from "../Utils" -import { BinaryNode, jidDecode, jidEncode, isJidStatusBroadcast, areJidsSameUser, getBinaryNodeChildren } from '../WABinary' +import { BinaryNode, jidDecode, jidEncode, isJidStatusBroadcast, areJidsSameUser, getBinaryNodeChildren, jidNormalizedUser } from '../WABinary' import { downloadIfHistory } from '../Utils/history' import { proto } from "../../WAProto" import { generateSignalPubKey, xmppPreKey, xmppSignedPreKey } from "../Utils/signal" @@ -426,7 +426,8 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => { const contactNameUpdates: { [_: string]: string } = { } for(const msg of messages) { if(!!msg.pushName) { - contactNameUpdates[msg.key.remoteJid!] = msg.pushName + const jid = msg.key.fromMe ? jidNormalizedUser(authState.creds.me!.id) : (msg.key.participant || msg.key.remoteJid) + contactNameUpdates[jid] = msg.pushName // update our pushname too if(msg.key.fromMe && authState.creds.me?.name !== msg.pushName) { authState.creds.me!.name = msg.pushName