Skip to content

GOWA - WhatsApp REST API with support for UI, Multi Account, Webhooks, and MCP, and Chatwoot. Built with Golang for efficient memory use.

feat: add support for Push-To-Video (PTV) messages

Aldino Kemal045d34f32519
diff --git a/src/infrastructure/whatsapp/event_message.go b/src/infrastructure/whatsapp/event_message.go
index 112f48eb..baa3e366 100644
--- a/src/infrastructure/whatsapp/event_message.go
+++ b/src/infrastructure/whatsapp/event_message.go
@@ -231,5 +231,22 @@ func createMessagePayload(ctx context.Context, evt *events.Message) (map[string]
}
}
+ // Handle PTV (Push-To-Video) messages - also known as "video notes" (circular video messages)
+ if ptvMedia := evt.Message.GetPtvMessage(); ptvMedia != nil {
+ if config.WhatsappAutoDownloadMedia {
+ path, err := utils.ExtractMedia(ctx, cli, config.PathMedia, ptvMedia)
+ if err != nil {
+ logrus.Errorf("Failed to download video note from %s: %v", evt.Info.SourceString(), err)
+ return nil, pkgError.WebhookError(fmt.Sprintf("Failed to download video note: %v", err))
+ }
+ body["video_note"] = path
+ } else {
+ body["video_note"] = map[string]any{
+ "url": ptvMedia.GetURL(),
+ "caption": ptvMedia.GetCaption(),
+ }
+ }
+ }
+
return body, nil
}
diff --git a/src/pkg/utils/whatsapp.go b/src/pkg/utils/whatsapp.go
index 8d3a6c7a..24d40562 100644
--- a/src/pkg/utils/whatsapp.go
+++ b/src/pkg/utils/whatsapp.go
@@ -273,6 +273,14 @@ func ExtractMediaInfo(msg *waE2E.Message) (mediaType string, filename string, ur
vid.GetFileEncSHA256(), vid.GetFileLength()
}
+ // Check for PTV (video note) message - circular video messages
+ if ptv := msg.GetPtvMessage(); ptv != nil {
+ filename = GenerateMediaFilename("video_note", "mp4", ptv.GetCaption())
+ return "video_note", filename,
+ ptv.GetURL(), ptv.GetMediaKey(), ptv.GetFileSHA256(),
+ ptv.GetFileEncSHA256(), ptv.GetFileLength()
+ }
+
// Check for audio message
if aud := msg.GetAudioMessage(); aud != nil {
extension := "ogg"