fix: build error

This commit is contained in:
ricael 2025-08-15 16:04:33 -03:00
parent 4ee4ee3a8b
commit ceb946c3dd

View File

@ -1052,11 +1052,9 @@ export class BaileysStartupService extends ChannelStartupService {
for (const received of messages) { for (const received of messages) {
if (received.key.remoteJid?.includes('@lid') && received.key.senderPn) { if (received.key.remoteJid?.includes('@lid') && received.key.senderPn) {
this.logger.verbose(`Processing @lid message: ${received.key.remoteJid} -> ${received.key.senderPn}`); this.logger.verbose(`Processing @lid message: ${received.key.remoteJid} -> ${received.key.senderPn}`);
const previousRemoteJid = received.key.remoteJid;
(received.key as { previousRemoteJid?: string | null }).previousRemoteJid = received.key.remoteJid;
received.key.remoteJid = received.key.senderPn; received.key.remoteJid = received.key.senderPn;
await this.updateContactFromLid(previousRemoteJid, received.key.remoteJid);
await this.updateContactFromLid(received.key.previousRemoteJid, received.key.remoteJid);
} }
if ( if (
received?.messageStubParameters?.some?.((param) => received?.messageStubParameters?.some?.((param) =>
@ -4067,7 +4065,7 @@ export class BaileysStartupService extends ChannelStartupService {
this.logger.info(`Successfully processed @lid update: ${lidJid} -> ${realJid}`); this.logger.info(`Successfully processed @lid update: ${lidJid} -> ${realJid}`);
} catch (error) { } catch (error) {
this.logger.error('Error updating contact from @lid:', error); this.logger.error(`Error updating contact from @lid: ${lidJid}`);
} }
} }
@ -4098,13 +4096,10 @@ export class BaileysStartupService extends ChannelStartupService {
// Tentar resolver o JID real através do WhatsApp // Tentar resolver o JID real através do WhatsApp
try { try {
// Usar o cliente WhatsApp para verificar se o contato existe // Usar o cliente WhatsApp para verificar se o contato existe
const contactInfo = await this.client.contactsUpsert([ const contactInfo = await this.client.onWhatsApp(contact.remoteJid);
{ id: contact.remoteJid, name: contact.pushName || 'Unknown' } if (contactInfo && contactInfo.length > 0 && contactInfo[0].jid && !contactInfo[0].jid.includes('@lid')) {
]);
if (contactInfo && contactInfo[0] && !contactInfo[0].id.includes('@lid')) {
// Contato foi resolvido, atualizar // Contato foi resolvido, atualizar
await this.updateContactFromLid(contact.remoteJid, contactInfo[0].id); await this.updateContactFromLid(contact.remoteJid, contactInfo[0].jid);
} else { } else {
// Contato não pode ser resolvido, remover // Contato não pode ser resolvido, remover
this.logger.warn(`Removing orphaned @lid contact: ${contact.remoteJid}`); this.logger.warn(`Removing orphaned @lid contact: ${contact.remoteJid}`);
@ -4139,12 +4134,10 @@ export class BaileysStartupService extends ChannelStartupService {
// Extrai o JID @lid da chave do cache // Extrai o JID @lid da chave do cache
const lidJid = key.split(':').pop(); const lidJid = key.split(':').pop();
// Usa o Baileys para tentar resolver o JID real // Usa o Baileys para tentar resolver o JID real
const contactInfo = await this.client.contactsUpsert([ const contactInfo = await this.client.onWhatsApp(lidJid);
{ id: lidJid, name: contactData.pushName || 'Unknown' } if (contactInfo && contactInfo.length > 0 && contactInfo[0].jid && !contactInfo[0].jid.includes('@lid')) {
]);
if (contactInfo && contactInfo[0] && !contactInfo[0].id.includes('@lid')) {
// Atualiza o cache para o JID real // Atualiza o cache para o JID real
const realContactKey = `contact:${this.instanceId}:${contactInfo[0].id}`; const realContactKey = `contact:${this.instanceId}:${contactInfo[0].jid}`;
await this.cache.hSet(this.instanceId, realContactKey, contactData); await this.cache.hSet(this.instanceId, realContactKey, contactData);
await this.cache.hDelete(this.instanceId, key); await this.cache.hDelete(this.instanceId, key);
this.logger.verbose(`Updated Redis cache contact from @lid: ${key} -> ${realContactKey}`); this.logger.verbose(`Updated Redis cache contact from @lid: ${key} -> ${realContactKey}`);
@ -4163,7 +4156,7 @@ export class BaileysStartupService extends ChannelStartupService {
this.logger.info('Completed cleanup of orphaned @lid contacts'); this.logger.info('Completed cleanup of orphaned @lid contacts');
} catch (error) { } catch (error) {
this.logger.error('Error during @lid cleanup:', error); this.logger.error(`Error during @lid cleanup`);
} }
} }