Skip to content

Commit 10f153a

Browse files
committed
Corrige filtro de mensagens com OR dinâmico para conseguir filtrar por remoteJid ou senderPn
1 parent 3960624 commit 10f153a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4480,6 +4480,7 @@ export class BaileysStartupService extends ChannelStartupService {
44804480
id?: string;
44814481
fromMe?: boolean;
44824482
remoteJid?: string;
4483+
senderPn?: string;
44834484
participants?: string;
44844485
};
44854486

@@ -4503,9 +4504,12 @@ export class BaileysStartupService extends ChannelStartupService {
45034504
AND: [
45044505
keyFilters?.id ? { key: { path: ['id'], equals: keyFilters?.id } } : {},
45054506
keyFilters?.fromMe ? { key: { path: ['fromMe'], equals: keyFilters?.fromMe } } : {},
4506-
keyFilters?.remoteJid ? { key: { path: ['remoteJid'], equals: keyFilters?.remoteJid } } : {},
45074507
keyFilters?.participants ? { key: { path: ['participants'], equals: keyFilters?.participants } } : {},
45084508
],
4509+
OR: [
4510+
keyFilters?.remoteJid ? { key: { path: ['remoteJid'], equals: keyFilters?.remoteJid } } : {},
4511+
keyFilters?.senderPn ? { key: { path: ['senderPn'], equals: keyFilters?.senderPn } } : {},
4512+
]
45094513
},
45104514
});
45114515

@@ -4527,9 +4531,12 @@ export class BaileysStartupService extends ChannelStartupService {
45274531
AND: [
45284532
keyFilters?.id ? { key: { path: ['id'], equals: keyFilters?.id } } : {},
45294533
keyFilters?.fromMe ? { key: { path: ['fromMe'], equals: keyFilters?.fromMe } } : {},
4530-
keyFilters?.remoteJid ? { key: { path: ['remoteJid'], equals: keyFilters?.remoteJid } } : {},
45314534
keyFilters?.participants ? { key: { path: ['participants'], equals: keyFilters?.participants } } : {},
45324535
],
4536+
OR: [
4537+
keyFilters?.remoteJid ? { key: { path: ['remoteJid'], equals: keyFilters?.remoteJid } } : {},
4538+
keyFilters?.senderPn ? { key: { path: ['senderPn'], equals: keyFilters?.senderPn } } : {},
4539+
]
45334540
},
45344541
orderBy: { messageTimestamp: 'desc' },
45354542
skip: query.offset * (query?.page === 1 ? 0 : (query?.page as number) - 1),

0 commit comments

Comments
 (0)