fix(chat): apply where filters correctly in findContacts endpoint#2120
Merged
DavidsonGomes merged 1 commit intoEvolutionAPI:developfrom Oct 23, 2025
Merged
fix(chat): apply where filters correctly in findContacts endpoint#2120DavidsonGomes merged 1 commit intoEvolutionAPI:developfrom
DavidsonGomes merged 1 commit intoEvolutionAPI:developfrom
Conversation
Anteriormente, o endpoint findContacts processava apenas o campo remoteJid da cláusula where, ignorando outros campos como id e pushName. Alterações: - Atualiza método fetchContacts para processar todos os campos do where (id, remoteJid, pushName) - Adiciona campo remoteJid ao contactValidateSchema para validação adequada - Garante isolamento multi-tenant mantendo filtro por instanceId Esta correção permite que usuários filtrem contatos por qualquer um dos campos suportados ao invés de sempre retornar todos os contatos da instância.
Contributor
Reviewer's guide (collapsed on small PRs)Reviewer's GuideFixes the chat findContacts endpoint by correctly applying all supported where filters (id, remoteJid, pushName) and updating validation to include remoteJid. Sequence diagram for findContacts endpoint with improved filteringsequenceDiagram
actor User
participant API
participant "ChannelStartupService"
participant Database
User->>API: POST /chat/findContacts (with where filters)
API->>"ChannelStartupService": fetchContacts(query)
"ChannelStartupService"->>Database: Query contacts with filters (id, remoteJid, pushName)
Database-->>"ChannelStartupService": Filtered contacts
"ChannelStartupService"-->>API: Return contacts
API-->>User: Respond with filtered contacts
Class diagram for updated Contact query and validationclassDiagram
class Contact {
+String id
+String remoteJid
+String pushName
+String _id
}
class ChannelStartupService {
+fetchContacts(query: Query<Contact>)
}
class contactValidateSchema {
+_id: String
+id: String
+pushName: String
+remoteJid: String
}
ChannelStartupService --> Contact : queries
contactValidateSchema --> Contact : validates
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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
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.
📋 Description
Corrige o endpoint
/chat/findContactsque estava ignorando os filtros da cláusulawhere, retornando sempre todos os contatos da instância. A implementação anterior processava apenas o camporemoteJid, ignorandoidepushName.Agora o método
fetchContactsprocessa corretamente todos os campos suportados dowhere:id- CUID do contato no banco de dadosremoteJid- Número do WhatsApp (ex:5511999999999@s.whatsapp.net)pushName- Nome de exibição do contato🔗 Related Issue
Closes #(2099)
🧪 Type of Change
🧪 Testing
Cenários testados:
📸 Screenshots (if applicable)
N/A - Correção de backend sem alterações visuais
✅ Checklist
📝 Additional Notes
Arquivos alterados:
src/api/services/channel.service.ts- Atualizado métodofetchContactspara processar todos os campos do wheresrc/validate/chat.schema.ts- Adicionado camporemoteJidao schema de validaçãoCompatibilidade:
Summary by Sourcery
Fix the chat/findContacts endpoint to correctly apply all supported where filters and update the request validation schema
Bug Fixes:
Enhancements: