Skip to content

Commit ceb946c

Browse files
author
ricael
committed
fix: build error
1 parent 4ee4ee3 commit ceb946c

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,11 +1052,9 @@ export class BaileysStartupService extends ChannelStartupService {
10521052
for (const received of messages) {
10531053
if (received.key.remoteJid?.includes('@lid') && received.key.senderPn) {
10541054
this.logger.verbose(`Processing @lid message: ${received.key.remoteJid} -> ${received.key.senderPn}`);
1055-
1056-
(received.key as { previousRemoteJid?: string | null }).previousRemoteJid = received.key.remoteJid;
1055+
const previousRemoteJid = received.key.remoteJid;
10571056
received.key.remoteJid = received.key.senderPn;
1058-
1059-
await this.updateContactFromLid(received.key.previousRemoteJid, received.key.remoteJid);
1057+
await this.updateContactFromLid(previousRemoteJid, received.key.remoteJid);
10601058
}
10611059
if (
10621060
received?.messageStubParameters?.some?.((param) =>
@@ -4067,7 +4065,7 @@ export class BaileysStartupService extends ChannelStartupService {
40674065

40684066
this.logger.info(`Successfully processed @lid update: ${lidJid} -> ${realJid}`);
40694067
} catch (error) {
4070-
this.logger.error('Error updating contact from @lid:', error);
4068+
this.logger.error(`Error updating contact from @lid: ${lidJid}`);
40714069
}
40724070
}
40734071

@@ -4098,13 +4096,10 @@ export class BaileysStartupService extends ChannelStartupService {
40984096
// Tentar resolver o JID real através do WhatsApp
40994097
try {
41004098
// Usar o cliente WhatsApp para verificar se o contato existe
4101-
const contactInfo = await this.client.contactsUpsert([
4102-
{ id: contact.remoteJid, name: contact.pushName || 'Unknown' }
4103-
]);
4104-
4105-
if (contactInfo && contactInfo[0] && !contactInfo[0].id.includes('@lid')) {
4099+
const contactInfo = await this.client.onWhatsApp(contact.remoteJid);
4100+
if (contactInfo && contactInfo.length > 0 && contactInfo[0].jid && !contactInfo[0].jid.includes('@lid')) {
41064101
// Contato foi resolvido, atualizar
4107-
await this.updateContactFromLid(contact.remoteJid, contactInfo[0].id);
4102+
await this.updateContactFromLid(contact.remoteJid, contactInfo[0].jid);
41084103
} else {
41094104
// Contato não pode ser resolvido, remover
41104105
this.logger.warn(`Removing orphaned @lid contact: ${contact.remoteJid}`);
@@ -4139,12 +4134,10 @@ export class BaileysStartupService extends ChannelStartupService {
41394134
// Extrai o JID @lid da chave do cache
41404135
const lidJid = key.split(':').pop();
41414136
// Usa o Baileys para tentar resolver o JID real
4142-
const contactInfo = await this.client.contactsUpsert([
4143-
{ id: lidJid, name: contactData.pushName || 'Unknown' }
4144-
]);
4145-
if (contactInfo && contactInfo[0] && !contactInfo[0].id.includes('@lid')) {
4137+
const contactInfo = await this.client.onWhatsApp(lidJid);
4138+
if (contactInfo && contactInfo.length > 0 && contactInfo[0].jid && !contactInfo[0].jid.includes('@lid')) {
41464139
// Atualiza o cache para o JID real
4147-
const realContactKey = `contact:${this.instanceId}:${contactInfo[0].id}`;
4140+
const realContactKey = `contact:${this.instanceId}:${contactInfo[0].jid}`;
41484141
await this.cache.hSet(this.instanceId, realContactKey, contactData);
41494142
await this.cache.hDelete(this.instanceId, key);
41504143
this.logger.verbose(`Updated Redis cache contact from @lid: ${key} -> ${realContactKey}`);
@@ -4163,7 +4156,7 @@ export class BaileysStartupService extends ChannelStartupService {
41634156

41644157
this.logger.info('Completed cleanup of orphaned @lid contacts');
41654158
} catch (error) {
4166-
this.logger.error('Error during @lid cleanup:', error);
4159+
this.logger.error(`Error during @lid cleanup`);
41674160
}
41684161
}
41694162

0 commit comments

Comments
 (0)