From fb826601d84e73097c7cc97603db54b4ce6361b1 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sat, 31 Aug 2019 00:32:51 +0300 Subject: [PATCH] Fix bridging media when whatsapp sends wrong mime type --- portal.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/portal.go b/portal.go index d799628..6f2363a 100644 --- a/portal.go +++ b/portal.go @@ -920,6 +920,10 @@ func (portal *Portal) HandleMediaMessage(source *User, download func() ([]byte, return } + // WhatsApp sends incorrect mime types 3:< + if detected := http.DetectContentType(data); detected != "application/octet-stream" { + mimeType = detected + } uploaded, err := intent.UploadBytes(data, mimeType) if err != nil { portal.log.Errorfln("Failed to upload media for %s: %v", err)