feat: support sending EventMessage (group events) - #4
Open
NeritonDias wants to merge 1 commit into
Open
Conversation
WhatsApp group events were effectively receive-only: getTypeFromMessage had no case for EventMessage, so the stanza was sent as type="text" and the client silently discarded it (server ACKs but the event never renders). The required <meta event_type="creation"> child node was also missing. - getTypeFromMessage: return "event" for EventMessage - add a <meta event_type="creation"> child node for event messages, mirroring the existing poll <meta polltype="creation"> handling The caller must set Message.MessageContextInfo.MessageSecret (32 bytes) so the event's responses (going/not_going) can be decrypted, the same way BuildPollCreation does for polls.
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds full support for sending WhatsApp group EventMessage stanzas by classifying them as type="event" and attaching the required node, so client.SendMessage with an EventMessage renders correctly as a group event in WhatsApp clients. File-Level Changes
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:
- The
getTypeFromMessagechange always mapsEventMessagetotype="event"; if there are non-creation event flows (e.g., updates or responses) that reuseEventMessage, consider making the stanza type selection more nuanced or clearly constrained to creation-only usage. - The
metanode injection fortype="event"is hard-coded toevent_type="creation"; if you anticipate other event lifecycle operations, it may be cleaner to thread the desiredevent_typefrom the caller or message contents rather than fixing it here.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `getTypeFromMessage` change always maps `EventMessage` to `type="event"`; if there are non-creation event flows (e.g., updates or responses) that reuse `EventMessage`, consider making the stanza type selection more nuanced or clearly constrained to creation-only usage.
- The `meta` node injection for `type="event"` is hard-coded to `event_type="creation"`; if you anticipate other event lifecycle operations, it may be cleaner to thread the desired `event_type` from the caller or message contents rather than fixing it here.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Author
|
🟢 👍 Contribuição mínima e aditiva: suporte a |
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
WhatsApp group events (
EventMessage) were effectively receive-only in whatsmeow — there was no way to create/send one. This adds the two missing pieces soclient.SendMessagewith anEventMessageactually renders as an event in the WhatsApp clients.Problem
When sending a
&waE2E.Message{EventMessage: ...}:getTypeFromMessagehad no case forEventMessage, so the stanza went out withtype="text". The server ACKs it, but clients silently discard it — it never renders as an event.<meta event_type="creation">child node that the protocol expects for event creation was missing (the same way polls require<meta polltype="creation">).Sending
type="event"without the meta node makes the server reject the stanza with error 479; with both, the event is created and renders correctly.Changes (
send.go)getTypeFromMessage: return"event"formsg.EventMessage.<meta event_type="creation">child node for event messages, mirroring the existing poll<meta polltype="creation">handling.Notes
Message.MessageContextInfo.MessageSecret(32 random bytes) so the event's responses (going/not_goingEncEventResponseMessage) decrypt — same pattern asBuildPollCreation.POST /send/eventendpoint in evolution-go.Summary by Sourcery
Support sending WhatsApp group EventMessage stanzas by treating them as event-type messages and including required creation metadata.
New Features:
Bug Fixes: