aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators/video-captions.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/custom-validators/video-captions.ts')
-rw-r--r--server/helpers/custom-validators/video-captions.ts21
1 files changed, 1 insertions, 20 deletions
diff --git a/server/helpers/custom-validators/video-captions.ts b/server/helpers/custom-validators/video-captions.ts
index 3b6569a8a..d06eb3695 100644
--- a/server/helpers/custom-validators/video-captions.ts
+++ b/server/helpers/custom-validators/video-captions.ts
@@ -1,8 +1,5 @@
1import { CONSTRAINTS_FIELDS, MIMETYPES, VIDEO_LANGUAGES } from '../../initializers/constants' 1import { CONSTRAINTS_FIELDS, MIMETYPES, VIDEO_LANGUAGES } from '../../initializers/constants'
2import { exists, isFileValid } from './misc' 2import { exists, isFileValid } from './misc'
3import { Response } from 'express'
4import { VideoModel } from '../../models/video/video'
5import { VideoCaptionModel } from '../../models/video/video-caption'
6 3
7function isVideoCaptionLanguageValid (value: any) { 4function isVideoCaptionLanguageValid (value: any) {
8 return exists(value) && VIDEO_LANGUAGES[ value ] !== undefined 5 return exists(value) && VIDEO_LANGUAGES[ value ] !== undefined
@@ -16,25 +13,9 @@ function isVideoCaptionFile (files: { [ fieldname: string ]: Express.Multer.File
16 return isFileValid(files, videoCaptionTypesRegex, field, CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.FILE_SIZE.max) 13 return isFileValid(files, videoCaptionTypesRegex, field, CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.FILE_SIZE.max)
17} 14}
18 15
19async function doesVideoCaptionExist (video: VideoModel, language: string, res: Response) {
20 const videoCaption = await VideoCaptionModel.loadByVideoIdAndLanguage(video.id, language)
21
22 if (!videoCaption) {
23 res.status(404)
24 .json({ error: 'Video caption not found' })
25 .end()
26
27 return false
28 }
29
30 res.locals.videoCaption = videoCaption
31 return true
32}
33
34// --------------------------------------------------------------------------- 16// ---------------------------------------------------------------------------
35 17
36export { 18export {
37 isVideoCaptionFile, 19 isVideoCaptionFile,
38 isVideoCaptionLanguageValid, 20 isVideoCaptionLanguageValid
39 doesVideoCaptionExist
40} 21}