Skip to content

feat(send): add POST /send/event endpoint#90

Open
NeritonDias wants to merge 2 commits into
evolution-foundation:developfrom
NeritonDias:feat/send-event
Open

feat(send): add POST /send/event endpoint#90
NeritonDias wants to merge 2 commits into
evolution-foundation:developfrom
NeritonDias:feat/send-event

Conversation

@NeritonDias

@NeritonDias NeritonDias commented Jun 24, 2026

Copy link
Copy Markdown

Summary

Adds POST /send/event to create and send WhatsApp Events (group agenda) — previously only possible manually from the app.

⚠️ Depends on evolution-foundation/whatsmeow#4 (event-stanza support). The bundled whatsmeow submodule needs that change for events to render — without it the stanza goes out as type="text" and the client silently discards it. Once #4 is merged, bump the submodule.

What's included

  • EventStruct request body with an EventTime type that accepts both ISO 8601 (RFC3339, with timezone) and epoch seconds for startTime/endTime.
  • SendEvent builds a waE2E.EventMessage and sets the required MessageContextInfo.MessageSecret (32 bytes via crypto/rand) so the event's going/not-going responses decrypt.
  • The flag booleans (isCanceled, isScheduleCall, extraGuestsAllowed) are always sent explicitly — the WhatsApp client requires them present, otherwise it ACKs but silently drops the event.
  • Optional text field, delivered as a leading message right before the event card (caption-style, since the event has no caption field), honoring mentionAll/mentionedJid/delay.
  • "EventMessage" handled in every SendMessage context-info switch (quoted, no-quoted, mentionAll, mentionedJid).
  • Route POST /send/event with the shared ValidateNumberFieldWithFormatJid middleware.
  • Swagger (docs/), CHANGELOG and Postman example updated.

Body fields

Required: number, name, startTime. Optional: description, endTime, location{name,latitude,longitude,address}, hasReminder + reminderOffsetSec (900=15min, 3600=1h, 86400=1 day), isScheduleCall, extraGuestsAllowed, isCanceled, mentionAll/mentionedJid, text, delay, quoted.

joinLink only accepts WhatsApp call links (call.whatsapp.com); external URLs (site/YouTube) belong in description.

Tested

Verified end-to-end against a real group: event creation, going/not-going responses, location, start/end time, reminder (15min/1h/1day), mentionAll, and the text caption — all rendering correctly. go build ./..., go vet ./pkg/sendMessage/... and make swagger pass (CGO enabled).

Create and send WhatsApp Events (the group agenda feature), which could
previously only be created manually from the app.

- EventStruct/EventLocationStruct body with an EventTime type that accepts
  both ISO 8601 (RFC3339) and epoch seconds for startTime/endTime
- SendEvent builds a waE2E.EventMessage and sets the required
  MessageContextInfo secret (same pattern as BuildPollCreation) so the
  event's going/not-going responses can be decrypted
- handle "EventMessage" in all SendMessage context-info switches
- route POST /send/event with the shared JID validation middleware
- regenerate Swagger docs, add CHANGELOG entry and Postman request

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

Sorry @NeritonDias, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

Follow-up to the /send/event endpoint so real events render in the
WhatsApp client and cover the full feature set:

- always send isCanceled/isScheduleCall/extraGuestsAllowed explicitly;
  the WhatsApp client requires these booleans present, otherwise it ACKs
  but silently discards the event
- add isScheduleCall to the request body
- add an optional `text` field, delivered as a leading message right
  before the event card (the event has no caption field), honoring
  mentionAll/mentionedJid/delay
- regenerate Swagger, update CHANGELOG and the Postman example

Note: joinLink only accepts WhatsApp call links (call.whatsapp.com);
external URLs (site/YouTube) belong in description. Requires the matching
event-stanza support in the bundled whatsmeow (type=event +
<meta event_type="creation">).
@oriondesign2015

Copy link
Copy Markdown

up

@NeritonDias

Copy link
Copy Markdown
Author

🟢 👍

Mira a develop (fluxo certo), está CLEAN e é aditivo: POST /send/event seguindo o padrão handler/service com registro pontual em routes.go, sem mexer em estrutura nem renomear nada. 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.

2 participants