aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-03-22 16:58:49 +0100
committerChocobozzz <me@florianbigard.com>2022-03-22 17:24:32 +0100
commit92e66e04f7f51d37b465cff442ce47f6d6d7cadd (patch)
tree4475c5c601c0f6673ca56afba5b7f70a4fae4ec3 /server/helpers/custom-validators
parent1808a1f8e4b7b102823492a2007a46929aebf189 (diff)
downloadPeerTube-92e66e04f7f51d37b465cff442ce47f6d6d7cadd.tar.gz
PeerTube-92e66e04f7f51d37b465cff442ce47f6d6d7cadd.tar.zst
PeerTube-92e66e04f7f51d37b465cff442ce47f6d6d7cadd.zip
Rename studio to editor
Diffstat (limited to 'server/helpers/custom-validators')
-rw-r--r--server/helpers/custom-validators/video-studio.ts (renamed from server/helpers/custom-validators/video-editor.ts)28
1 files changed, 14 insertions, 14 deletions
diff --git a/server/helpers/custom-validators/video-editor.ts b/server/helpers/custom-validators/video-studio.ts
index 09238675e..19e7906d5 100644
--- a/server/helpers/custom-validators/video-editor.ts
+++ b/server/helpers/custom-validators/video-studio.ts
@@ -1,40 +1,40 @@
1import validator from 'validator' 1import validator from 'validator'
2import { CONSTRAINTS_FIELDS } from '@server/initializers/constants' 2import { CONSTRAINTS_FIELDS } from '@server/initializers/constants'
3import { buildTaskFileFieldname } from '@server/lib/video-editor' 3import { buildTaskFileFieldname } from '@server/lib/video-studio'
4import { VideoEditorTask } from '@shared/models' 4import { VideoStudioTask } from '@shared/models'
5import { isArray } from './misc' 5import { isArray } from './misc'
6import { isVideoFileMimeTypeValid, isVideoImageValid } from './videos' 6import { isVideoFileMimeTypeValid, isVideoImageValid } from './videos'
7 7
8function isValidEditorTasksArray (tasks: any) { 8function isValidStudioTasksArray (tasks: any) {
9 if (!isArray(tasks)) return false 9 if (!isArray(tasks)) return false
10 10
11 return tasks.length >= CONSTRAINTS_FIELDS.VIDEO_EDITOR.TASKS.min && 11 return tasks.length >= CONSTRAINTS_FIELDS.VIDEO_STUDIO.TASKS.min &&
12 tasks.length <= CONSTRAINTS_FIELDS.VIDEO_EDITOR.TASKS.max 12 tasks.length <= CONSTRAINTS_FIELDS.VIDEO_STUDIO.TASKS.max
13} 13}
14 14
15function isEditorCutTaskValid (task: VideoEditorTask) { 15function isStudioCutTaskValid (task: VideoStudioTask) {
16 if (task.name !== 'cut') return false 16 if (task.name !== 'cut') return false
17 if (!task.options) return false 17 if (!task.options) return false
18 18
19 const { start, end } = task.options 19 const { start, end } = task.options
20 if (!start && !end) return false 20 if (!start && !end) return false
21 21
22 if (start && !validator.isInt(start + '', CONSTRAINTS_FIELDS.VIDEO_EDITOR.CUT_TIME)) return false 22 if (start && !validator.isInt(start + '', CONSTRAINTS_FIELDS.VIDEO_STUDIO.CUT_TIME)) return false
23 if (end && !validator.isInt(end + '', CONSTRAINTS_FIELDS.VIDEO_EDITOR.CUT_TIME)) return false 23 if (end && !validator.isInt(end + '', CONSTRAINTS_FIELDS.VIDEO_STUDIO.CUT_TIME)) return false
24 24
25 if (!start || !end) return true 25 if (!start || !end) return true
26 26
27 return parseInt(start + '') < parseInt(end + '') 27 return parseInt(start + '') < parseInt(end + '')
28} 28}
29 29
30function isEditorTaskAddIntroOutroValid (task: VideoEditorTask, indice: number, files: Express.Multer.File[]) { 30function isStudioTaskAddIntroOutroValid (task: VideoStudioTask, indice: number, files: Express.Multer.File[]) {
31 const file = files.find(f => f.fieldname === buildTaskFileFieldname(indice, 'file')) 31 const file = files.find(f => f.fieldname === buildTaskFileFieldname(indice, 'file'))
32 32
33 return (task.name === 'add-intro' || task.name === 'add-outro') && 33 return (task.name === 'add-intro' || task.name === 'add-outro') &&
34 file && isVideoFileMimeTypeValid([ file ], null) 34 file && isVideoFileMimeTypeValid([ file ], null)
35} 35}
36 36
37function isEditorTaskAddWatermarkValid (task: VideoEditorTask, indice: number, files: Express.Multer.File[]) { 37function isStudioTaskAddWatermarkValid (task: VideoStudioTask, indice: number, files: Express.Multer.File[]) {
38 const file = files.find(f => f.fieldname === buildTaskFileFieldname(indice, 'file')) 38 const file = files.find(f => f.fieldname === buildTaskFileFieldname(indice, 'file'))
39 39
40 return task.name === 'add-watermark' && 40 return task.name === 'add-watermark' &&
@@ -44,9 +44,9 @@ function isEditorTaskAddWatermarkValid (task: VideoEditorTask, indice: number, f
44// --------------------------------------------------------------------------- 44// ---------------------------------------------------------------------------
45 45
46export { 46export {
47 isValidEditorTasksArray, 47 isValidStudioTasksArray,
48 48
49 isEditorCutTaskValid, 49 isStudioCutTaskValid,
50 isEditorTaskAddIntroOutroValid, 50 isStudioTaskAddIntroOutroValid,
51 isEditorTaskAddWatermarkValid 51 isStudioTaskAddWatermarkValid
52} 52}