diff options
Diffstat (limited to 'server/helpers/custom-validators/video-captions.ts')
-rw-r--r-- | server/helpers/custom-validators/video-captions.ts | 21 |
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 @@ | |||
1 | import { CONSTRAINTS_FIELDS, MIMETYPES, VIDEO_LANGUAGES } from '../../initializers/constants' | 1 | import { CONSTRAINTS_FIELDS, MIMETYPES, VIDEO_LANGUAGES } from '../../initializers/constants' |
2 | import { exists, isFileValid } from './misc' | 2 | import { exists, isFileValid } from './misc' |
3 | import { Response } from 'express' | ||
4 | import { VideoModel } from '../../models/video/video' | ||
5 | import { VideoCaptionModel } from '../../models/video/video-caption' | ||
6 | 3 | ||
7 | function isVideoCaptionLanguageValid (value: any) { | 4 | function 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 | ||
19 | async 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 | ||
36 | export { | 18 | export { |
37 | isVideoCaptionFile, | 19 | isVideoCaptionFile, |
38 | isVideoCaptionLanguageValid, | 20 | isVideoCaptionLanguageValid |
39 | doesVideoCaptionExist | ||
40 | } | 21 | } |