Corrige filtro de mensagens com OR dinâmico para conseguir filtrar por remoteJid ou senderPn

This commit is contained in:
Anderson de Lima 2025-07-30 18:20:59 -03:00
parent 39606240da
commit 10f153a951

View File

@ -4480,6 +4480,7 @@ export class BaileysStartupService extends ChannelStartupService {
id?: string; id?: string;
fromMe?: boolean; fromMe?: boolean;
remoteJid?: string; remoteJid?: string;
senderPn?: string;
participants?: string; participants?: string;
}; };
@ -4503,9 +4504,12 @@ export class BaileysStartupService extends ChannelStartupService {
AND: [ AND: [
keyFilters?.id ? { key: { path: ['id'], equals: keyFilters?.id } } : {}, keyFilters?.id ? { key: { path: ['id'], equals: keyFilters?.id } } : {},
keyFilters?.fromMe ? { key: { path: ['fromMe'], equals: keyFilters?.fromMe } } : {}, keyFilters?.fromMe ? { key: { path: ['fromMe'], equals: keyFilters?.fromMe } } : {},
keyFilters?.remoteJid ? { key: { path: ['remoteJid'], equals: keyFilters?.remoteJid } } : {},
keyFilters?.participants ? { key: { path: ['participants'], equals: keyFilters?.participants } } : {}, keyFilters?.participants ? { key: { path: ['participants'], equals: keyFilters?.participants } } : {},
], ],
OR: [
keyFilters?.remoteJid ? { key: { path: ['remoteJid'], equals: keyFilters?.remoteJid } } : {},
keyFilters?.senderPn ? { key: { path: ['senderPn'], equals: keyFilters?.senderPn } } : {},
]
}, },
}); });
@ -4527,9 +4531,12 @@ export class BaileysStartupService extends ChannelStartupService {
AND: [ AND: [
keyFilters?.id ? { key: { path: ['id'], equals: keyFilters?.id } } : {}, keyFilters?.id ? { key: { path: ['id'], equals: keyFilters?.id } } : {},
keyFilters?.fromMe ? { key: { path: ['fromMe'], equals: keyFilters?.fromMe } } : {}, keyFilters?.fromMe ? { key: { path: ['fromMe'], equals: keyFilters?.fromMe } } : {},
keyFilters?.remoteJid ? { key: { path: ['remoteJid'], equals: keyFilters?.remoteJid } } : {},
keyFilters?.participants ? { key: { path: ['participants'], equals: keyFilters?.participants } } : {}, keyFilters?.participants ? { key: { path: ['participants'], equals: keyFilters?.participants } } : {},
], ],
OR: [
keyFilters?.remoteJid ? { key: { path: ['remoteJid'], equals: keyFilters?.remoteJid } } : {},
keyFilters?.senderPn ? { key: { path: ['senderPn'], equals: keyFilters?.senderPn } } : {},
]
}, },
orderBy: { messageTimestamp: 'desc' }, orderBy: { messageTimestamp: 'desc' },
skip: query.offset * (query?.page === 1 ? 0 : (query?.page as number) - 1), skip: query.offset * (query?.page === 1 ? 0 : (query?.page as number) - 1),