{{ message }}
Permitir correta utilização da evolution quando mensagens não são persistidas no DB#1798
Merged
DavidsonGomes merged 8 commits intoEvolutionAPI:developfrom Aug 4, 2025
Merged
Conversation
…lvar mensagens no banco
Contributor
Contributor
There was a problem hiding this comment.
Hey @onerrogus - I've reviewed your changes - here's some feedback:
- Cache the DATABASE.SAVE_DATA config at the start of the method or as a class property to avoid repeating configService.get calls and improve readability.
- Extract the conditional logic for historic, new message, and message update handling into dedicated helper methods to reduce nesting and duplication.
- Centralize the SAVE_DATA flag checks into a single guard or utility function to ensure consistent behavior across all message operations.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Cache the DATABASE.SAVE_DATA config at the start of the method or as a class property to avoid repeating configService.get calls and improve readability.
- Extract the conditional logic for historic, new message, and message update handling into dedicated helper methods to reduce nesting and duplication.
- Centralize the SAVE_DATA flag checks into a single guard or utility function to ensure consistent behavior across all message operations.
## Individual Comments
### Comment 1
<location> `src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts:3789` </location>
<code_context>
private async formatUpdateMessage(data: UpdateMessageDto) {
try {
+ if (!this.configService.get<Database>('DATABASE').SAVE_DATA.NEW_MESSAGE) {
+ return data;
+ }
</code_context>
<issue_to_address>
Early return skips formatting if NEW_MESSAGE is false.
Ensure that all consumers of this method are prepared to handle unformatted data when NEW_MESSAGE is false, as this may affect downstream processing.
</issue_to_address>
### Comment 2
<location> `src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts:3852` </location>
<code_context>
const messageId = messageSent.message?.protocolMessage?.key?.id;
- if (messageId) {
+ if (messageId && this.configService.get<Database>('DATABASE').SAVE_DATA.NEW_MESSAGE) {
let message = await this.prismaRepository.message.findFirst({
where: { key: { path: ['id'], equals: messageId } },
</code_context>
<issue_to_address>
Message update logic is now gated by NEW_MESSAGE flag.
Consider whether message updates should ever occur when NEW_MESSAGE is false, as this change will prevent all such updates.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
|
||
| private async formatUpdateMessage(data: UpdateMessageDto) { | ||
| try { | ||
| if (!this.configService.get<Database>('DATABASE').SAVE_DATA.NEW_MESSAGE) { |
Contributor
There was a problem hiding this comment.
question (bug_risk): Early return skips formatting if NEW_MESSAGE is false.
Ensure that all consumers of this method are prepared to handle unformatted data when NEW_MESSAGE is false, as this may affect downstream processing.
|
|
||
| const messageId = messageSent.message?.protocolMessage?.key?.id; | ||
| if (messageId) { | ||
| if (messageId && this.configService.get<Database>('DATABASE').SAVE_DATA.NEW_MESSAGE) { |
Contributor
There was a problem hiding this comment.
question (bug_risk): Message update logic is now gated by NEW_MESSAGE flag.
Consider whether message updates should ever occur when NEW_MESSAGE is false, as this change will prevent all such updates.
Contributor
Author
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.

Summary by Sourcery
Add configuration flags to control message persistence and history retrieval, enabling selective saving and logging of incoming messages and updates based on SAVE_DATA settings
Enhancements: