Skip to content

Commit 57ea670

Browse files
committed
feat: convert LID to phoneNumber on
GROUP_PARTICIPANTS_UPDATE
1 parent 78c7b96 commit 57ea670

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

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

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,12 +1591,38 @@ export class BaileysStartupService extends ChannelStartupService {
15911591
});
15921592
},
15931593

1594-
'group-participants.update': (participantsUpdate: {
1594+
'group-participants.update': async (participantsUpdate: {
15951595
id: string;
15961596
participants: string[];
15971597
action: ParticipantAction;
15981598
}) => {
1599-
this.sendDataWebhook(Events.GROUP_PARTICIPANTS_UPDATE, participantsUpdate);
1599+
try {
1600+
// Usa o mesmo método que o endpoint /group/participants
1601+
const groupParticipants = await this.findParticipants({ groupJid: participantsUpdate.id });
1602+
1603+
// Filtra apenas os participantes que estão no evento
1604+
const resolvedParticipants = participantsUpdate.participants.map((participantId) => {
1605+
const participantData = groupParticipants.participants.find(p => p.id === participantId);
1606+
1607+
return {
1608+
jid: participantId,
1609+
phoneNumber: participantData?.phoneNumber || participantId,
1610+
name: participantData?.name,
1611+
imgUrl: participantData?.imgUrl,
1612+
};
1613+
});
1614+
1615+
const enhancedParticipantsUpdate = {
1616+
...participantsUpdate,
1617+
participants: resolvedParticipants
1618+
};
1619+
1620+
this.sendDataWebhook(Events.GROUP_PARTICIPANTS_UPDATE, enhancedParticipantsUpdate);
1621+
} catch (error) {
1622+
console.log('Erro ao buscar dados dos participantes para webhook:', error);
1623+
// Fallback - envia sem conversão
1624+
this.sendDataWebhook(Events.GROUP_PARTICIPANTS_UPDATE, participantsUpdate);
1625+
}
16001626

16011627
this.updateGroupMetadataCache(participantsUpdate.id);
16021628
},

0 commit comments

Comments
 (0)