-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Corrige filtro de mensagens com OR dinâmico #1780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
anderecc
wants to merge
2
commits into
EvolutionAPI:develop
Choose a base branch
from
anderecc:fix/filtro-mensagens-com-senderpn-ou-remotejid
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Corrige filtro de mensagens com OR dinâmico #1780
anderecc
wants to merge
2
commits into
EvolutionAPI:develop
from
anderecc:fix/filtro-mensagens-com-senderpn-ou-remotejid
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…r remoteJid ou senderPn
Reviewer's GuideRefactors WhatsApp message filtering in Prisma queries to dynamically combine remoteJid and senderPn conditions using an OR operator while retaining existing AND filters. Class diagram for updated message filter parametersclassDiagram
class KeyFilters {
id: string
fromMe: boolean
remoteJid: string
senderPn: string
participants: string
}
Flow diagram for dynamic OR filtering in message queriesflowchart TD
A[Receive keyFilters input] --> B{Build Prisma where clause}
B --> C[Add AND filters: id, fromMe, participants]
B --> D[Add OR filters: remoteJid, senderPn]
C --> E[Execute count or findMany query]
D --> E
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @anderecc - I've reviewed your changes - here's some feedback:
- The OR filter should be nested inside the AND array (e.g. AND: […, { OR: […] }]) to preserve the intended A AND (B OR C) logic rather than placing OR at the top level.
- Build the OR array dynamically by only adding objects when keyFilters.remoteJid/senderPn is defined, so you don’t include empty filter objects that could match everything unexpectedly.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The OR filter should be nested inside the AND array (e.g. AND: […, { OR: […] }]) to preserve the intended A AND (B OR C) logic rather than placing OR at the top level.
- Build the OR array dynamically by only adding objects when keyFilters.remoteJid/senderPn is defined, so you don’t include empty filter objects that could match everything unexpectedly.
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
…r remoteJid ou senderPn
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adicionado operador OR em "prismaRepository.message.count" e "prismaRepository.message.findMany" para filtrar as mensagens de um contato por "remoteJid" ou "senderPn".
Essa atualização serve para ajudar a buscar as mensagens do cliente que vem com o campo "remoteJid" com @lid.
Essa atualização permite trazer os resultados mais corretos para o filtro de mensagem, sem deixar as mensagens com senderPn que deveriam ter o padrão @WhatsApp que vinha antes em remoteJid.
Essa atualização busca com o where da seguinte forma:
where: {
key: {
remoteJid: '',
senderPn: '',
},
}
Acredito que sirva para mais pessoas essa att, outra forma seria nem passar o senderPn no where e colocar direto no método de count ou findMany... Mas dessa forma acredito que fique melhor o uso...
Summary by Sourcery
Allow filtering messages by either remoteJid or senderPn by adding dynamic OR conditions to Prisma message queries
Enhancements: