diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-23 18:04:48 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:53 +0100 |
commit | d4f1e94c89336255537b0b82913591f00e716201 (patch) | |
tree | c7d18e09a4f53eafc61de8cb0692c020b197512d /server/helpers/custom-validators/videos.ts | |
parent | 8d468a16fd33ec2660c3c59b3f7def53eb0cc4a1 (diff) | |
download | PeerTube-d4f1e94c89336255537b0b82913591f00e716201.tar.gz PeerTube-d4f1e94c89336255537b0b82913591f00e716201.tar.zst PeerTube-d4f1e94c89336255537b0b82913591f00e716201.zip |
Misc cleanup
Diffstat (limited to 'server/helpers/custom-validators/videos.ts')
-rw-r--r-- | server/helpers/custom-validators/videos.ts | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts index c893d2c7c..205d8c62f 100644 --- a/server/helpers/custom-validators/videos.ts +++ b/server/helpers/custom-validators/videos.ts | |||
@@ -90,12 +90,20 @@ function isVideoFile (files: { [ fieldname: string ]: Express.Multer.File[] } | | |||
90 | return new RegExp('^video/(webm|mp4|ogg)$', 'i').test(file.mimetype) | 90 | return new RegExp('^video/(webm|mp4|ogg)$', 'i').test(file.mimetype) |
91 | } | 91 | } |
92 | 92 | ||
93 | function isVideoPrivacyValid (value: string) { | ||
94 | return VIDEO_PRIVACIES[value] !== undefined | ||
95 | } | ||
96 | |||
93 | function isVideoFileInfoHashValid (value: string) { | 97 | function isVideoFileInfoHashValid (value: string) { |
94 | return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.INFO_HASH) | 98 | return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.INFO_HASH) |
95 | } | 99 | } |
96 | 100 | ||
97 | function isVideoPrivacyValid (value: string) { | 101 | function isVideoFileResolutionValid (value: string) { |
98 | return VIDEO_PRIVACIES[value] !== undefined | 102 | return exists(value) && validator.isInt(value + '') |
103 | } | ||
104 | |||
105 | function isVideoFileSizeValid (value: string) { | ||
106 | return exists(value) && validator.isInt(value + '', VIDEOS_CONSTRAINTS_FIELDS.FILE_SIZE) | ||
99 | } | 107 | } |
100 | 108 | ||
101 | function checkVideoExists (id: string, res: Response, callback: () => void) { | 109 | function checkVideoExists (id: string, res: Response, callback: () => void) { |
@@ -142,5 +150,7 @@ export { | |||
142 | isVideoTagValid, | 150 | isVideoTagValid, |
143 | isVideoUrlValid, | 151 | isVideoUrlValid, |
144 | isVideoPrivacyValid, | 152 | isVideoPrivacyValid, |
153 | isVideoFileResolutionValid, | ||
154 | isVideoFileSizeValid, | ||
145 | checkVideoExists | 155 | checkVideoExists |
146 | } | 156 | } |