Insert contant without the pushName if fromMe but update it later

This commit is contained in:
Pedro Howat 2024-09-24 10:12:59 -03:00
parent 54c74da015
commit 2c76098d59

View File

@ -1227,7 +1227,7 @@ export class BaileysStartupService extends ChannelStartupService {
this.logger.verbose('Contact found in database'); this.logger.verbose('Contact found in database');
const contactRaw: ContactRaw = { const contactRaw: ContactRaw = {
id: received.key.remoteJid, id: received.key.remoteJid,
pushName: contact[0].pushName, pushName: contact[0].pushName || received.pushName,
profilePictureUrl: (await this.profilePicture(received.key.remoteJid)).profilePictureUrl, profilePictureUrl: (await this.profilePicture(received.key.remoteJid)).profilePictureUrl,
owner: this.instance.name, owner: this.instance.name,
}; };
@ -1255,8 +1255,10 @@ export class BaileysStartupService extends ChannelStartupService {
this.logger.verbose('Inserting contact in database'); this.logger.verbose('Inserting contact in database');
if (received?.key?.fromMe === false) if (received?.key?.fromMe === true) {
this.repository.contact.insert([contactRaw], this.instance.name, database.SAVE_DATA.CONTACTS); contactRaw.pushName = null;
}
this.repository.contact.insert([contactRaw], this.instance.name, database.SAVE_DATA.CONTACTS);
} }
} catch (error) { } catch (error) {
this.logger.error(error); this.logger.error(error);