]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/custom-validators/video-captions.ts
Merge branch 'release/2.1.0' into develop
[github/Chocobozzz/PeerTube.git] / server / helpers / custom-validators / video-captions.ts
index 3b6569a8ae757f8ff71f341b214eaa5a496c73a0..9abbce04a110b3e7fae1b1fb5429ae6303b808df 100644 (file)
@@ -1,11 +1,8 @@
 import { CONSTRAINTS_FIELDS, MIMETYPES, VIDEO_LANGUAGES } from '../../initializers/constants'
 import { exists, isFileValid } from './misc'
-import { Response } from 'express'
-import { VideoModel } from '../../models/video/video'
-import { VideoCaptionModel } from '../../models/video/video-caption'
 
 function isVideoCaptionLanguageValid (value: any) {
-  return exists(value) && VIDEO_LANGUAGES[ value ] !== undefined
+  return exists(value) && VIDEO_LANGUAGES[value] !== undefined
 }
 
 const videoCaptionTypes = Object.keys(MIMETYPES.VIDEO_CAPTIONS.MIMETYPE_EXT)
@@ -16,25 +13,9 @@ function isVideoCaptionFile (files: { [ fieldname: string ]: Express.Multer.File
   return isFileValid(files, videoCaptionTypesRegex, field, CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.FILE_SIZE.max)
 }
 
-async function doesVideoCaptionExist (video: VideoModel, language: string, res: Response) {
-  const videoCaption = await VideoCaptionModel.loadByVideoIdAndLanguage(video.id, language)
-
-  if (!videoCaption) {
-    res.status(404)
-       .json({ error: 'Video caption not found' })
-       .end()
-
-    return false
-  }
-
-  res.locals.videoCaption = videoCaption
-  return true
-}
-
 // ---------------------------------------------------------------------------
 
 export {
   isVideoCaptionFile,
-  isVideoCaptionLanguageValid,
-  doesVideoCaptionExist
+  isVideoCaptionLanguageValid
 }