feat: adiciona endpoints de status do WhatsApp para texto, imagem e vídeo#15
Open
Eduardo-gato wants to merge 3 commits intoEvolutionAPI:mainfrom
Open
feat: adiciona endpoints de status do WhatsApp para texto, imagem e vídeo#15Eduardo-gato wants to merge 3 commits intoEvolutionAPI:mainfrom
Eduardo-gato wants to merge 3 commits intoEvolutionAPI:mainfrom
Conversation
added 2 commits
April 5, 2026 11:14
- Add POST /send/status/text endpoint for sending text status - Add POST /send/status/media endpoint for sending image/video status - Support both JSON (URL) and multipart/form-data (file upload) - Use Upload() with encryption for proper WhatsApp status format - Add HTTP status code validation for URL downloads - Add docker-compose.run.yml for local development
- Add OpenAPI docs for POST /send/status/text - Add OpenAPI docs for POST /send/status/media (supports JSON and multipart) - Add StatusTextStruct and StatusMediaStruct definitions - Add Swagger annotations to handler functions
Reviewer's GuideAdds WhatsApp Status (stories) sending support (text and image/video) via new service methods, HTTP handlers, routes, and Swagger documentation, plus a compose file to run the app locally with Postgres. Sequence diagram for sending WhatsApp media status via URLsequenceDiagram
actor ApiClient
participant GinRouter
participant SendHandler
participant SendService
participant WhatsmeowClient
participant WhatsAppServers
participant WebhookService
participant GlobalQueue
ApiClient->>GinRouter: POST /send/status/media (JSON body)
GinRouter->>SendHandler: SendStatusMedia(ctx)
SendHandler->>SendHandler: Detect ContentType != multipart/form-data
SendHandler->>SendHandler: ShouldBindBodyWithJSON(StatusMediaStruct)
SendHandler->>SendHandler: Validate Url and Type (image/video)
SendHandler->>SendService: SendStatusMediaUrl(StatusMediaStruct, Instance)
SendService->>SendService: ensureClientConnected(instance.Id)
SendService->>ExternalHTTP: GET media URL
ExternalHTTP-->>SendService: 2xx + file bytes
SendService->>SendService: sendStatusMedia(client, data, fileData, instance)
SendService->>WhatsmeowClient: Upload(fileData, MediaImage|MediaVideo)
WhatsmeowClient-->>SendService: Uploaded info (URL, DirectPath, keys)
SendService->>WhatsmeowClient: SendMessage(status@broadcast, media, ID)
WhatsmeowClient-->>WhatsAppServers: Encrypted status message
WhatsAppServers-->>WhatsmeowClient: Ack (ServerID)
WhatsmeowClient-->>SendService: Send response
SendService->>SendService: Build MessageSendStruct
SendService->>WebhookService: CallWebhook(instance, sendstatus, payload)
alt Global queues enabled
SendService->>GlobalQueue: SendToGlobalQueues(SendStatus, payload)
end
SendService-->>SendHandler: MessageSendStruct
SendHandler-->>ApiClient: 200 OK + data
Updated class diagram for send service and status structsclassDiagram
class SendService {
<<interface>>
SendContact(data *ContactStruct, instance *Instance) (*MessageSendStruct, error)
SendButton(data *ButtonStruct, instance *Instance) (*MessageSendStruct, error)
SendList(data *ListStruct, instance *Instance) (*MessageSendStruct, error)
SendStatusText(data *StatusTextStruct, instance *Instance) (*MessageSendStruct, error)
SendStatusMediaUrl(data *StatusMediaStruct, instance *Instance) (*MessageSendStruct, error)
SendStatusMediaFile(data *StatusMediaStruct, fileData []byte, instance *Instance) (*MessageSendStruct, error)
}
class sendService {
clientPointer map[string]*WhatsmeowClient
whatsmeowService WhatsmeowService
loggerWrapper LoggerWrapper
config Config
SendStatusText(data *StatusTextStruct, instance *Instance) (*MessageSendStruct, error)
SendStatusMediaUrl(data *StatusMediaStruct, instance *Instance) (*MessageSendStruct, error)
SendStatusMediaFile(data *StatusMediaStruct, fileData []byte, instance *Instance) (*MessageSendStruct, error)
sendStatusMedia(client *WhatsmeowClient, data *StatusMediaStruct, fileData []byte, instance *Instance) (*MessageSendStruct, error)
}
class StatusTextStruct {
string Text
string Id
int32 Font
string BackgroundColor
}
class StatusMediaStruct {
string Type
string Url
string Caption
string Id
}
class MessageSendStruct {
MessageInfo Info
Message Message
ContextInfo MessageContextInfo
}
class SendHandler {
SendContact(ctx *Context)
SendButton(ctx *Context)
SendList(ctx *Context)
SendStatusText(ctx *Context)
SendStatusMedia(ctx *Context)
}
class Instance {
string Id
string Name
string Token
}
class WhatsmeowClient {
GenerateMessageID() string
Upload(ctx Context, data []byte, mediaType MediaType) (UploadedMedia, error)
SendMessage(ctx Context, jid JID, msg Message, extra SendRequestExtra) (SendResponse, error)
}
SendService <|.. sendService
sendService --> StatusTextStruct
sendService --> StatusMediaStruct
sendService --> MessageSendStruct
SendHandler --> SendService
SendHandler --> StatusTextStruct
SendHandler --> StatusMediaStruct
sendService --> WhatsmeowClient
MessageSendStruct --> Instance
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 found 1 issue, and left some high level feedback:
- In both SendStatusText and SendStatusMedia handlers you declare
var data *StatusTextStruct/*StatusMediaStructand then callShouldBindBodyWithJSON(&data), which passes a**Tto the binder; switch to using a value (var data StatusTextStruct) or a pointer (data := new(StatusTextStruct)) and pass it directly to avoid incorrect or failed binding. - StatusTextStruct exposes
fontandbackgroundColorfields and they are documented in Swagger, but SendStatusText ignores them when building the waE2E message; either apply those fields to the underlying WhatsApp message (if supported) or drop them from the API to avoid confusing clients. - The webhook/queue emission and message envelope assembly logic in SendStatusText and sendStatusMedia is almost identical; consider extracting this into a shared helper to reduce duplication and keep future changes to the event payload in one place.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In both SendStatusText and SendStatusMedia handlers you declare `var data *StatusTextStruct/*StatusMediaStruct` and then call `ShouldBindBodyWithJSON(&data)`, which passes a `**T` to the binder; switch to using a value (`var data StatusTextStruct`) or a pointer (`data := new(StatusTextStruct)`) and pass it directly to avoid incorrect or failed binding.
- StatusTextStruct exposes `font` and `backgroundColor` fields and they are documented in Swagger, but SendStatusText ignores them when building the waE2E message; either apply those fields to the underlying WhatsApp message (if supported) or drop them from the API to avoid confusing clients.
- The webhook/queue emission and message envelope assembly logic in SendStatusText and sendStatusMedia is almost identical; consider extracting this into a shared helper to reduce duplication and keep future changes to the event payload in one place.
## Individual Comments
### Comment 1
<location path="pkg/sendMessage/service/send_service.go" line_range="249-253" />
<code_context>
Cards []CarouselCardStruct `json:"cards"`
}
+type StatusTextStruct struct {
+ Text string `json:"text"`
+ Id string `json:"id"`
+ Font int32 `json:"font,omitempty"`
+ BackgroundColor string `json:"backgroundColor,omitempty"`
+}
+
</code_context>
<issue_to_address>
**question (bug_risk):** StatusTextStruct exposes font/backgroundColor but SendStatusText ignores them
`Font` and `BackgroundColor` are documented but never used in `SendStatusText`, which only sets `ExtendedTextMessage.Text`. This mismatch can mislead API consumers about what’s actually supported. Consider either wiring these fields through (if WhatsApp supports them) or removing them from the struct/docs to keep behavior aligned with the API surface.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
- Fix binding: use new() instead of var with pointer-to-pointer - Remove unused font and backgroundColor fields from StatusTextStruct - Extract webhook/queue logic into shared sendStatusWebhook helper - Update Swagger docs to reflect StatusTextStruct changes
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.
Description
This PR adds support for sending WhatsApp status (stories) to
status@broadcast, including text, images, and video status updates.Features Added:
POST /send/status/text- Send text status to WhatsAppPOST /send/status/media- Send image/video status (supports JSON with URL and multipart/form-data)Related Issue
Closes #(issue_number)
Type of Change
Testing
Screenshots (if applicable)
N/A
Checklist
Summary by Sourcery
Add support for sending WhatsApp status (stories) as text and media messages and expose them via new HTTP endpoints.
New Features:
Enhancements:
Build: