diff --git a/go.mod b/go.mod index 178fc70..73626dd 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.14 require ( github.com/chai2010/webp v1.1.0 + github.com/gabriel-vasile/mimetype v1.1.2 github.com/gorilla/websocket v1.4.2 github.com/kelaresg/go-skypeapi v0.1.2-0.20210220112556-a87881796d7b github.com/lib/pq v1.7.0 diff --git a/go.sum b/go.sum index 4c5ae4b..a5b19c2 100644 --- a/go.sum +++ b/go.sum @@ -64,6 +64,8 @@ github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8 github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/gabriel-vasile/mimetype v1.1.2 h1:gaPnPcNor5aZSVCJVSGipcpbgMWiAAj9z182ocSGbHU= +github.com/gabriel-vasile/mimetype v1.1.2/go.mod h1:6CDPel/o/3/s4+bp6kIbsWATq8pmgOisOPG40CJa6To= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= diff --git a/portal.go b/portal.go index 4c453d8..192e404 100644 --- a/portal.go +++ b/portal.go @@ -2,6 +2,7 @@ package main import ( "bytes" + "github.com/gabriel-vasile/mimetype" "maunium.net/go/mautrix/patch" "encoding/hex" @@ -1622,8 +1623,7 @@ func (portal *Portal) HandleMediaMessageSkype(source *User, download func(conn * } // synapse doesn't handle webp well, so we convert it. This can be dropped once https://github.com/matrix-org/synapse/issues/4382 is fixed - mimeType := http.DetectContentType(data) - //length := len(data) + mimeType := mimetype.Detect(data).String() if mimeType == "image/webp" { img, err := decodeWebp(bytes.NewReader(data)) if err != nil {