Skip to content

feat: support sending EventMessage (group events) - #4

Open
NeritonDias wants to merge 1 commit into
evolution-foundation:mainfrom
NeritonDias:feat/send-event-support
Open

feat: support sending EventMessage (group events)#4
NeritonDias wants to merge 1 commit into
evolution-foundation:mainfrom
NeritonDias:feat/send-event-support

Conversation

@NeritonDias

@NeritonDias NeritonDias commented Jun 25, 2026

Copy link
Copy Markdown

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 so client.SendMessage with an EventMessage actually renders as an event in the WhatsApp clients.

Problem

When sending a &waE2E.Message{EventMessage: ...}:

  • getTypeFromMessage had no case for EventMessage, so the stanza went out with type="text". The server ACKs it, but clients silently discard it — it never renders as an event.
  • The <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)

  1. getTypeFromMessage: return "event" for msg.EventMessage.
  2. Append a <meta event_type="creation"> child node for event messages, mirroring the existing poll <meta polltype="creation"> handling.

Notes

  • The caller must set Message.MessageContextInfo.MessageSecret (32 random bytes) so the event's responses (going/not_going EncEventResponseMessage) decrypt — same pattern as BuildPollCreation.
  • Verified end-to-end against a real group: events render with title, description, location, start/end time, reminder and mentions; the going/not-going responses decrypt correctly.
  • Enables the POST /send/event endpoint 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:

  • Allow EventMessage-based group events to be sent via client.SendMessage so they render as events in WhatsApp clients.

Bug Fixes:

  • Ensure EventMessage stanzas use the correct "event" type instead of "text" to prevent clients from discarding them.
  • Add required event creation meta node to avoid server errors and enable successful event creation.

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.
@sourcery-ai

sourcery-ai Bot commented Jun 25, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds 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

Change Details Files
Classify EventMessage messages as type="event" in stanza generation so they’re not treated as text.
  • Extend message type resolution to detect non-nil EventMessage fields.
  • Return the stanza type string "event" when an EventMessage is present, keeping existing handling for reactions, polls, media, and text as-is.
send.go
Emit the required meta node for event creation when building event message content.
  • Detect when the resolved message type is "event" during stanza content construction.
  • Append a child node alongside existing content, mirroring the existing pattern for poll meta nodes.
  • Ensure the new meta node is added before any optional bot node content so ordering matches other meta elements.
send.go

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • 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.
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.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@NeritonDias

Copy link
Copy Markdown
Author

🟢 👍

Contribuição mínima e aditiva: suporte a EventMessage (case event no getTypeFromMessage + nó de meta), 1 arquivo, sem reescrever nada. Obs: este repo não tem branch develop, então avaliei contra a main mesmo. Pode seguir.

@dpaes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant