Skip to content

Commit cd00eff

Browse files
Merge pull request #421 from judsonjuniorr/Groups-participant-names
Refactor fetching participants for group in WhatsApp service
2 parents 1cd0334 + 6995e8a commit cd00eff

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/whatsapp/services/whatsapp.service.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4081,7 +4081,19 @@ export class WAStartupService {
40814081
this.logger.verbose('Fetching participants for group: ' + id.groupJid);
40824082
try {
40834083
const participants = (await this.client.groupMetadata(id.groupJid)).participants;
4084-
return { participants };
4084+
const contacts = await this.repository.contact.findManyById({
4085+
owner: this.instance.name,
4086+
ids: participants.map((p) => p.id),
4087+
});
4088+
const parsedParticipants = participants.map((participant) => {
4089+
const contact = contacts.find((c) => c.id === participant.id);
4090+
return {
4091+
...participant,
4092+
name: participant.name ?? contact?.pushName,
4093+
imgUrl: participant.imgUrl ?? contact?.profilePictureUrl,
4094+
};
4095+
});
4096+
return { participants: parsedParticipants };
40854097
} catch (error) {
40864098
throw new NotFoundException('No participants', error.toString());
40874099
}

0 commit comments

Comments
 (0)