Corrigindo um bug no endpoint de findChats e permitindo paginação nos endpoints de findChats e findContacts by pedro-php · Pull Request #1334 · EvolutionAPI/evolution-api · GitHub
Skip to content

Corrigindo um bug no endpoint de findChats e permitindo paginação nos endpoints de findChats e findContacts#1334

Merged
DavidsonGomes merged 2 commits intoEvolutionAPI:developfrom
adaptwebtech:fix_and_add_name_to_find_chats_and_paginate_get_contacts_and_get_chats
Mar 26, 2025
Merged

Corrigindo um bug no endpoint de findChats e permitindo paginação nos endpoints de findChats e findContacts#1334
DavidsonGomes merged 2 commits intoEvolutionAPI:developfrom
adaptwebtech:fix_and_add_name_to_find_chats_and_paginate_get_contacts_and_get_chats

Conversation

@pedro-php
Copy link
Copy Markdown
Contributor

@pedro-php pedro-php commented Mar 25, 2025

Fix

Problema

Ao enviar uma mensagem via dispositivo, dois comportamentos distintos ocorriam:

  1. Inicialmente, o evento MESSAGES_UPSERT atualizava o campo name da tabela Chat com o pushname do remetente.
  2. Em seguida, o evento MESSAGES_UPDATE sobrescrevia o campo name com uma string vazia de forma consistente, pois tentava fazer um update 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?

  • O campo name da tabela Chat não é mais atualizado durante o evento MESSAGES_UPDATE.
  • No evento MESSAGES_UPSERT, o campo name só é atualizado quando fromMe 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 tabela Chat (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.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Mar 25, 2025

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a 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 and offset 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

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread src/api/services/channel.service.ts Outdated
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
@MateusHirataAW
Copy link
Copy Markdown

up

1 similar comment
@marcosgalupo
Copy link
Copy Markdown

@DavidsonGomes DavidsonGomes changed the base branch from main to develop March 26, 2025 12:59
@DavidsonGomes DavidsonGomes merged commit b89f114 into EvolutionAPI:develop Mar 26, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants