]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/custom-validators/video-captions.ts
Add federation to ownership change
[github/Chocobozzz/PeerTube.git] / server / helpers / custom-validators / video-captions.ts
index fd4dc740b31fd4fac0c400a3d38cf859eafb4365..177e9e86ed45b475e1e9f007bb3ad2c091a00023 100644 (file)
@@ -1,4 +1,4 @@
-import { CONSTRAINTS_FIELDS, VIDEO_LANGUAGES } from '../../initializers'
+import { CONSTRAINTS_FIELDS, VIDEO_CAPTIONS_MIMETYPE_EXT, VIDEO_LANGUAGES } from '../../initializers'
 import { exists, isFileValid } from './misc'
 import { Response } from 'express'
 import { VideoModel } from '../../models/video/video'
@@ -8,13 +8,12 @@ function isVideoCaptionLanguageValid (value: any) {
   return exists(value) && VIDEO_LANGUAGES[ value ] !== undefined
 }
 
-const videoCaptionTypes = CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.EXTNAME
-                                          .map(v => v.replace('.', ''))
-                                          .join('|')
-const videoCaptionsTypesRegex = `text/(${videoCaptionTypes})`
-
+const videoCaptionTypes = Object.keys(VIDEO_CAPTIONS_MIMETYPE_EXT)
+                                .concat([ 'application/octet-stream' ]) // MacOS sends application/octet-stream ><
+                                .map(m => `(${m})`)
+const videoCaptionTypesRegex = videoCaptionTypes.join('|')
 function isVideoCaptionFile (files: { [ fieldname: string ]: Express.Multer.File[] } | Express.Multer.File[], field: string) {
-  return isFileValid(files, videoCaptionsTypesRegex, field, CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.FILE_SIZE.max)
+  return isFileValid(files, videoCaptionTypesRegex, field, CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.FILE_SIZE.max)
 }
 
 async function isVideoCaptionExist (video: VideoModel, language: string, res: Response) {