fix: mentionsEveryOne always active even when set to false#2470
Open
enzowilliam wants to merge 1 commit intoEvolutionAPI:mainfrom
Open
fix: mentionsEveryOne always active even when set to false#2470enzowilliam wants to merge 1 commit intoEvolutionAPI:mainfrom
enzowilliam wants to merge 1 commit intoEvolutionAPI:mainfrom
Conversation
- Changed truthy check to strict equality (=== true) to properly handle string values like "false" sent by clients (e.g., n8n) - Fixed validation schema property name from 'everyOne' to 'mentionsEveryOne' to match DTO and service code Fixes EvolutionAPI#2431 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Contributor
Reviewer's guide (collapsed on small PRs)Reviewer's GuideFixes WhatsApp group mention logic so that mentionsEveryOne only triggers when explicitly set to true, and aligns JSON message validation schemas with the DTO by renaming the everyOne flag to mentionsEveryOne across all message types. Sequence diagram for WhatsApp group message mentionsEveryOne handlingsequenceDiagram
actor Client
participant MessageAPI
participant Validator
participant BaileysStartupService
participant WhatsAppGroup
Client->>MessageAPI: sendGroupMessage(groupId, content, options)
MessageAPI->>Validator: validate(content, options) using messageSchema
Validator-->>MessageAPI: validationResult (mentionsEveryOne boolean)
MessageAPI->>BaileysStartupService: sendGroupMessage(groupId, content, options)
BaileysStartupService->>WhatsAppGroup: getGroup(groupId)
WhatsAppGroup-->>BaileysStartupService: group(participants)
alt mentionsEveryOne explicitly true
BaileysStartupService->>BaileysStartupService: if options.mentionsEveryOne === true
BaileysStartupService->>BaileysStartupService: mentions = group.participants.ids
else mentioned list provided
BaileysStartupService->>BaileysStartupService: else if options.mentioned.length > 0
BaileysStartupService->>BaileysStartupService: mentions = options.mentioned.ids
else no mentions
BaileysStartupService->>BaileysStartupService: mentions = []
end
BaileysStartupService-->>MessageAPI: send result
MessageAPI-->>Client: response
Class diagram for BaileysStartupService and message mention optionsclassDiagram
class BaileysStartupService {
+sendGroupMessage(groupId, content, options)
}
class MessageOptions {
+boolean mentionsEveryOne
+string[] mentioned
}
class TextMessageSchema {
+boolean mentionsEveryOne
}
class MediaMessageSchema {
+boolean mentionsEveryOne
}
class PtvMessageSchema {
+boolean mentionsEveryOne
}
class AudioMessageSchema {
+boolean mentionsEveryOne
}
class StickerMessageSchema {
+boolean mentionsEveryOne
}
class LocationMessageSchema {
+boolean mentionsEveryOne
}
class PollMessageSchema {
+boolean mentionsEveryOne
}
class ListMessageSchema {
+boolean mentionsEveryOne
}
class ButtonsMessageSchema {
+boolean mentionsEveryOne
}
BaileysStartupService --> MessageOptions : uses
MessageOptions <.. TextMessageSchema : validated_by
MessageOptions <.. MediaMessageSchema : validated_by
MessageOptions <.. PtvMessageSchema : validated_by
MessageOptions <.. AudioMessageSchema : validated_by
MessageOptions <.. StickerMessageSchema : validated_by
MessageOptions <.. LocationMessageSchema : validated_by
MessageOptions <.. PollMessageSchema : validated_by
MessageOptions <.. ListMessageSchema : validated_by
MessageOptions <.. ButtonsMessageSchema : validated_by
File-Level Changes
Assessment against linked issues
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 - I've left some high level feedback:
- The
options?.mentionsEveryOne === truecheck fixes the immediate bug but will now ignore a string'true'; consider normalizing this field at the validation/DTO layer (e.g., coercing'true'/'false'to booleans) so the service logic can stay simple and robust to client quirks. - Since the schema property was renamed from
everyOnetomentionsEveryOne, double-check any other internal usages or serializers that might still refer toeveryOneto avoid inconsistent payload shapes at the boundaries.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `options?.mentionsEveryOne === true` check fixes the immediate bug but will now ignore a string `'true'`; consider normalizing this field at the validation/DTO layer (e.g., coercing `'true'`/`'false'` to booleans) so the service logic can stay simple and robust to client quirks.
- Since the schema property was renamed from `everyOne` to `mentionsEveryOne`, double-check any other internal usages or serializers that might still refer to `everyOne` to avoid inconsistent payload shapes at the boundaries.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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
mentionsEveryOnewas always active even when set tofalseeveryOne→mentionsEveryOne)Root Cause
The check
if (options?.mentionsEveryOne)used truthy evaluation. When clients (like n8n) send"false"as a string instead of a boolean, JavaScript evaluates it as truthy because it's a non-empty string.Changes
whatsapp.baileys.service.ts: Changed truthy check to strict equality (=== true)message.schema.ts: RenamedeveryOnetomentionsEveryOnein all message schemas to match DTOTest plan
mentionsEveryOne: false→ should NOT mention anyonementionsEveryOne: true→ should mention everyonementionsEveryOne→ should NOT mention anyoneFixes #2431
🤖 Generated with Claude Code
Summary by Sourcery
Align WhatsApp group mention handling with the message DTO and prevent unintended @everyone mentions when the option is false or omitted.
Bug Fixes:
mentionsEveryOneonly triggers @everyone mentions when explicitly set to true, avoiding truthy evaluation of string values like "false".mentionsEveryOneinstead of the mismatchedeveryOneproperty so options are validated and mapped consistently across message types.