GOWA - WhatsApp REST API with support for UI, Multi Account, Webhooks, and MCP, and Chatwoot. Built with Golang for efficient memory use.
Go botgogolanggolang-whatsappgolang-whatsapp-apirestrest-apiwhatsappwhatsapp-apiwhatsapp-api-gowhatsapp-multi-devicewhatsapp-web-multi-device
fix: parse opus file extensions correctly (#612)
Faaz M33b6509e771b
diff --git a/src/infrastructure/chatwoot/client.go b/src/infrastructure/chatwoot/client.goindex 5ad5f446..429912cd 100644--- a/src/infrastructure/chatwoot/client.go+++ b/src/infrastructure/chatwoot/client.go@@ -516,10 +516,15 @@ func (c *Client) createMessageWithAttachments(endpoint, content, messageType strdefer file.Close()fileName := filepath.Base(fp)+ ext := filepath.Ext(fp)- mimeType := mime.TypeByExtension(filepath.Ext(fp))+ mimeType := mime.TypeByExtension(ext)if mimeType == "" {- mimeType = "application/octet-stream"+ if ext == ".oga" {+ mimeType = "audio/ogg"+ } else {+ mimeType = "application/octet-stream"+ }}// Custom form part with correct Content-Type for Chatwoot to render images inlinediff --git a/src/infrastructure/chatwoot/sync_test.go b/src/infrastructure/chatwoot/sync_test.goindex e6e699d6..5af063e0 100644--- a/src/infrastructure/chatwoot/sync_test.go+++ b/src/infrastructure/chatwoot/sync_test.go@@ -162,8 +162,8 @@ func TestGetExtensionForMediaType(t *testing.T) {}{{"image", "", ".jpg"},{"video", "", ".mp4"},- {"audio", "", ".ogg"},- {"ptt", "", ".ogg"},+ {"audio", "", ".oga"},+ {"ptt", "", ".oga"},{"document", "", ".bin"},{"sticker", "", ".webp"},{"unknown", "", ""},diff --git a/src/pkg/utils/whatsapp.go b/src/pkg/utils/whatsapp.goindex f550be81..3d403d8e 100644--- a/src/pkg/utils/whatsapp.go+++ b/src/pkg/utils/whatsapp.go@@ -73,6 +73,10 @@ func determineMediaExtension(originalFilename, mimeType string) string {}}+ if idx := strings.Index(mimeType, ";"); idx >= 0 {+ mimeType = strings.TrimSpace(mimeType[:idx])+ }+if ext, ok := resolveKnownDocumentExtension(mimeType); ok {return ext}diff --git a/src/pkg/utils/whatsapp_test.go b/src/pkg/utils/whatsapp_test.goindex 369d9048..301c2502 100644--- a/src/pkg/utils/whatsapp_test.go+++ b/src/pkg/utils/whatsapp_test.go@@ -33,6 +33,12 @@ func TestDetermineMediaExtension(t *testing.T) {mimeType: "application/zip",wantSuffix: ".zip",},+ {+ name: "AudioOgaWithCodecsParam",+ filename: "",+ mimeType: "audio/ogg; codecs=opus",+ wantSuffix: ".oga",+ },{name: "ExeFromFilename",filename: "installer.exe",