fix: fetchChats e chat - Painel de mensagens no Manager#2160
Merged
DavidsonGomes merged 1 commit intoEvolutionAPI:developfrom Nov 7, 2025
Merged
Conversation
Contributor
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR refactors the cleanMessageData method in ChannelStartupService by adding guards against undefined message objects and reorganizing the extraction, deletion, and restoration of mediaUrl and base64 properties to prevent runtime errors when loading chats in the manager. Sequence diagram for cleanMessageData error prevention flowsequenceDiagram
participant S as ChannelStartupService
participant M as Message
S->>M: Check if message exists
alt message is undefined/null
S-->>S: Return message
else message exists
S->>M: Extract mediaUrl
S->>M: Delete base64
S->>M: Clean imageMessage (if exists)
S->>M: Clean documentWithCaptionMessage (if exists)
S->>M: Restore mediaUrl (if exists)
end
S-->>S: Return cleanedMessage
Class diagram for updated ChannelStartupService.cleanMessageData methodclassDiagram
class ChannelStartupService {
+cleanMessageData(message: any): any
}
class Message {
mediaUrl
base64
imageMessage
documentWithCaptionMessage
}
ChannelStartupService --> Message : cleans
Message --> ImageMessage
Message --> DocumentWithCaptionMessage
class ImageMessage {
url
}
class DocumentWithCaptionMessage {
url
name
}
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- Consider defining a proper Message interface instead of using
anyto improve type safety and clarity in cleanMessageData. - You could simplify the null-checks and property deletions using optional chaining (e.g.,
cleanedMessage.message?.base64) and object spread to make the code more concise.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider defining a proper Message interface instead of using `any` to improve type safety and clarity in cleanMessageData.
- You could simplify the null-checks and property deletions using optional chaining (e.g., `cleanedMessage.message?.base64`) and object spread to make the code more concise.
## Individual Comments
### Comment 1
<location> `src/api/services/channel.service.ts:586` </location>
<code_context>
}
- }
- if (mediaUrl) cleanedMessage.message.mediaUrl = mediaUrl;
+ if (mediaUrl) cleanedMessage.message.mediaUrl = mediaUrl;
+ }
</code_context>
<issue_to_address>
**suggestion:** Reassigning mediaUrl may be redundant if it was not modified.
If mediaUrl remains unchanged during cleaning, this reassignment can be removed for clarity.
```suggestion
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
Hoje aconteceu novamente, e ao invés de recriar, eu busquei as últimas mensagens no banco de dados. Encontrei um registro na tabela |
1 task
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
Modificação simples que previne erros de acesso à propriedades não definidas de objetos, que interrompem o fluxo do /chat/findChats e fazem com o que os chats no manager não sejam carregados.
Resolve esses erros:
🔗 Related Issue
Closes #2058
🧪 Type of Change
🧪 Testing
✅ Checklist
Summary by Sourcery
Fix null and undefined property access in cleanMessageData to prevent chat loading failures
Bug Fixes:
Enhancements: