mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-21 19:47:21 -06:00
Refactor fetching participants for group in WhatsApp service
This commit is contained in:
parent
525daff5fe
commit
6995e8a451
@ -4077,7 +4077,19 @@ export class WAStartupService {
|
|||||||
this.logger.verbose('Fetching participants for group: ' + id.groupJid);
|
this.logger.verbose('Fetching participants for group: ' + id.groupJid);
|
||||||
try {
|
try {
|
||||||
const participants = (await this.client.groupMetadata(id.groupJid)).participants;
|
const participants = (await this.client.groupMetadata(id.groupJid)).participants;
|
||||||
return { participants };
|
const contacts = await this.repository.contact.findManyById({
|
||||||
|
owner: this.instance.name,
|
||||||
|
ids: participants.map((p) => p.id),
|
||||||
|
});
|
||||||
|
const parsedParticipants = participants.map((participant) => {
|
||||||
|
const contact = contacts.find((c) => c.id === participant.id);
|
||||||
|
return {
|
||||||
|
...participant,
|
||||||
|
name: participant.name ?? contact?.pushName,
|
||||||
|
imgUrl: participant.imgUrl ?? contact?.profilePictureUrl,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
return { participants: parsedParticipants };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new NotFoundException('No participants', error.toString());
|
throw new NotFoundException('No participants', error.toString());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user