-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Corrigindo um bug no endpoint de findChats e permitindo paginação nos endpoints de findChats e findContacts #1334
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
Reviewer's Guide by SourceryThis pull request fixes a bug in the Sequence diagram for fetching chat namesequenceDiagram
participant Client
participant ChannelStartupService
participant PrismaRepository
Client->>ChannelStartupService: Calls findChats endpoint
ChannelStartupService->>PrismaRepository: Executes raw SQL query to fetch chats
PrismaRepository-->>ChannelStartupService: Returns chat data including chatName from Chat table
ChannelStartupService-->>Client: Returns chat data with correct chatName
Sequence diagram for Contact PaginationsequenceDiagram
participant Client
participant ChannelStartupService
participant PrismaRepository
Client->>ChannelStartupService: Calls findContacts endpoint with page and offset
ChannelStartupService->>PrismaRepository: Calls contact.findMany with take and skip parameters
PrismaRepository-->>ChannelStartupService: Returns paginated contact data
ChannelStartupService-->>Client: Returns paginated contact data
Updated class diagram for ChannelStartupServiceclassDiagram
class ChannelStartupService {
+findContacts(query: any): Promise<Contact[]>
+findChats(query: any): Promise<Chat[]>
}
class Contact {
id: string
remoteJid: string
pushName: string
chatName: string
profilePicUrl: string
updatedAt: Date
windowStart: Date
}
note for Contact "Added chatName attribute"
class Chat {
name: string
createdAt: Date
}
ChannelStartupService -- Contact : returns
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 @pedro-php - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider adding validation to ensure that
page
andoffset
are positive integers. - It might be worth extracting the pagination logic into a separate helper function to improve readability.
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
up |
1 similar comment
up |
Fix
Problema
Ao enviar uma mensagem via dispositivo, dois comportamentos distintos ocorriam:
MESSAGES_UPSERT
atualizava o camponame
da tabelaChat
com opushname
do remetente.MESSAGES_UPDATE
sobrescrevia o camponame
com uma string vazia de forma consistente, pois tentava fazer umupdate
utilizando uma variável que sequer era definida — já que esse campo não era enviado pelo respectivo evento da Baileys.O que foi alterado?
name
da tabelaChat
não é mais atualizado durante o eventoMESSAGES_UPDATE
.MESSAGES_UPSERT
, o camponame
só é atualizado quandofromMe
for falso, ou seja, apenas quando a mensagem for recebida (não enviada pelo próprio usuário).Resolução
Agora, ao chamar um endpoint que retorna o campo
name
da tabelaChat
(como o/chat/findChats/
), o valor retornado será o correto — evitando strings vazias ou o nome do próprio remetente. O campo continua sendo atualizado normalmente ao receber mensagens.