Skip to content

Commit eeedfb0

Browse files
authored
fetchContacts - nestordavalos
1 parent 3ab75fa commit eeedfb0

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/api/services/channel.service.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,20 @@ export class ChannelStartupService {
513513
contactFindManyArgs.skip = query.offset * (validPage - 1);
514514
}
515515

516-
return await this.prismaRepository.contact.findMany(contactFindManyArgs);
516+
const contacts = await this.prismaRepository.contact.findMany(contactFindManyArgs);
517+
518+
return contacts.map((contact) => {
519+
const remoteJid = contact.remoteJid;
520+
const isGroup = remoteJid.endsWith('@g.us');
521+
const isSaved = !!contact.pushName || !!contact.profilePicUrl;
522+
const type = isGroup ? 'group' : isSaved ? 'contact' : 'group_member';
523+
return {
524+
...contact,
525+
isGroup,
526+
isSaved,
527+
type,
528+
};
529+
});
517530
}
518531

519532
public cleanMessageData(message: any) {

0 commit comments

Comments
 (0)