소스 검색

Fix bridging media when whatsapp sends wrong mime type

Tulir Asokan 5 년 전
부모
커밋
fb826601d8
1개의 변경된 파일4개의 추가작업 그리고 0개의 파일을 삭제
  1. 4 0
      portal.go

+ 4 - 0
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)