send: add BuildReply helper for quoting messages#1147
Open
jobasfernandes wants to merge 1 commit into
Open
Conversation
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.
Adds
Client.BuildReply, following the same pattern asBuildRevoke/BuildEdit/BuildPollVote. Today callers have to hand-buildContextInfo, pick the right field per message type, promoteConversationtoExtendedTextMessage, and remember to strip the nestedQuotedMessageto avoid transitive quote chains.BuildReplydoes all of that, matching what the official WhatsApp clients do before embedding a quoted message.ContextInfo.QuotedMessagecleared. When anExtendedTextMessageends up with onlyTextafter the strip, it is downgraded toConversationto match what the official client emits.Conversationreply content toExtendedTextMessage.ContextInfoalready on the reply content (mentions, forwarding flags).Participantto the bot's own JID (PN or LID, matching the quoted message's server) for self-quotes, otherwiseSender.ToNonAD().ErrUnsupportedReplyTypefor content types with noContextInfofield (reactions, protocol messages, etc.).Purely additive - callers that build
ContextInfomanually are unaffected.Example:
The same helper works for media replies - set
ImageMessage/VideoMessage/DocumentMessage/etc. on the reply content andBuildReplyinjects theContextInfointo the right field.If you prefer something simpler, I can do it like this:
which builds the
ContextInfoonly, with the caller setting it on whichever message field they choose. No per-type switch, no auto promotion/downgrade, no field injection.Checklist