-
Notifications
You must be signed in to change notification settings - Fork 4.7k
fix: fetchChats e chat - Painel de mensagens no Manager #2160
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
base: develop
Are you sure you want to change the base?
fix: fetchChats e chat - Painel de mensagens no Manager #2160
Conversation
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
|
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 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 |

📋 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: