-
Couldn't load subscription status.
- Fork 4.6k
fix(chat): apply where filters correctly in findContacts endpoint #2120
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
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.
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
|
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.
📋 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: