Procházet zdrojové kódy

Always set a MIME type when sending files

If the browser could not determine the MIME type, fall back to
`application/octet-stream`.
Danilo Bargen před 8 roky
rodič
revize
1b15af1daf
1 změnil soubory, kde provedl 7 přidání a 5 odebrání
  1. 7 5
      src/partials/messenger.ts

+ 7 - 5
src/partials/messenger.ts

@@ -383,11 +383,13 @@ class ConversationController {
                 case 'file':
                     // Determine file type
                     let showSendAsFileCheckbox = false;
-                    for (let msg of contents) {
-                        const mime = (msg as threema.FileMessageData).fileType;
-                        if (this.mimeService.isImage(mime)
-                            || this.mimeService.isAudio(mime)
-                            || this.mimeService.isVideo(mime)) {
+                    for (let msg of contents as threema.FileMessageData[]) {
+                        if (!msg.fileType) {
+                            msg.fileType = 'application/octet-stream';
+                        }
+                        if (this.mimeService.isImage(msg.fileType)
+                            || this.mimeService.isAudio(msg.fileType)
+                            || this.mimeService.isVideo(msg.fileType)) {
                             showSendAsFileCheckbox = true;
                             break;
                         }