fix(send): handle document-with-caption and @lid JIDs in mentionAll - #137
Open
cesar-carlos wants to merge 1 commit into
Open
fix(send): handle document-with-caption and @lid JIDs in mentionAll#137cesar-carlos wants to merge 1 commit into
cesar-carlos wants to merge 1 commit into
Conversation
Document+caption moves DocumentMessage under DocumentWithCaptionMessage but mentionAll still wrote ContextInfo on the nil pointer. Prefer PhoneNumber over LID when building mention JIDs. Closes evolution-foundation#114 Co-authored-by: Cursor <cursoragent@cursor.com>
Reviewer's GuideRefactors how MentionedJID is set on outgoing messages, fixes crashes when sending document-with-caption messages with mentions, and ensures mention-all uses phone-number JIDs instead of @lid JIDs, with new helpers and unit tests to cover the behavior. Sequence diagram for mentionAll handling with document-with-caption messagessequenceDiagram
actor Client
participant SendService
participant GroupInfo
participant MentionHelpers
participant WAMessage
Client->>SendService: SendMessage(instance, msg)
SendService->>GroupInfo: groupInfo.Participants
loop participants
SendService->>MentionHelpers: participantMentionJID(participant)
MentionHelpers-->>SendService: mentionJID
end
SendService->>MentionHelpers: setMessageMentionedJIDs(msg, messageType, mentionedJIDs)
alt [messageType is DocumentMessage]
alt [message has DocumentMessage]
MentionHelpers->>WAMessage: msg.DocumentMessage.ContextInfo.MentionedJID = mentionedJIDs
else [message has DocumentWithCaptionMessage]
MentionHelpers->>WAMessage: msg.DocumentWithCaptionMessage.Message.DocumentMessage.ContextInfo.MentionedJID = mentionedJIDs
end
else [other message types]
MentionHelpers->>WAMessage: <type>.ContextInfo.MentionedJID = mentionedJIDs
end
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
setMessageMentionedJIDsrelies on themessageTypestring; consider refactoring callers to pass a more structured enum/constant or derive the type from the populated message field to avoid bugs from typos or mismatches between the string and the actual message content.- In
setMessageMentionedJIDs, it might be useful to handle or log unexpected/unsupportedmessageTypevalues (e.g., via a default case) so that future message types fail visibly instead of silently doing nothing.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- `setMessageMentionedJIDs` relies on the `messageType` string; consider refactoring callers to pass a more structured enum/constant or derive the type from the populated message field to avoid bugs from typos or mismatches between the string and the actual message content.
- In `setMessageMentionedJIDs`, it might be useful to handle or log unexpected/unsupported `messageType` values (e.g., via a default case) so that future message types fail visibly instead of silently doing nothing.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
/send/mediasends a document with caption together withmentionAll/mentionedJid(DocumentMessage is moved underDocumentWithCaptionMessagebut ContextInfo was still written on the nil pointer).participant.PhoneNumberover@lidJID when buildingmentionAlllists (WhatsApp mentions need@s.whatsapp.net).setMessageMentionedJIDs/participantMentionJIDhelpers and add unit tests.Closes #114
Test plan
go test ./pkg/sendMessage/service/ -run 'TestParticipantMentionJID|TestSetMessageMentionedJIDs'go vet ./pkg/sendMessage/service/POST /send/mediato a group withtype=document, caption,mentionAll=truereturns 200 and notifies participantstype=image+ caption +mentionAll=trueMade with Cursor
Summary by Sourcery
Fix mention handling for group messages, especially documents with captions, and centralize mention JID selection and assignment logic.
Bug Fixes:
Enhancements:
Tests: