diff options
Diffstat (limited to 'server/helpers')
-rw-r--r-- | server/helpers/custom-validators/accounts.ts | 5 | ||||
-rw-r--r-- | server/helpers/custom-validators/videos.ts | 14 |
2 files changed, 13 insertions, 6 deletions
diff --git a/server/helpers/custom-validators/accounts.ts b/server/helpers/custom-validators/accounts.ts index 83540e545..fe0fc650a 100644 --- a/server/helpers/custom-validators/accounts.ts +++ b/server/helpers/custom-validators/accounts.ts | |||
@@ -1,14 +1,11 @@ | |||
1 | import * as Promise from 'bluebird' | 1 | import * as Promise from 'bluebird' |
2 | import * as validator from 'validator' | ||
3 | import * as express from 'express' | 2 | import * as express from 'express' |
4 | import 'express-validator' | 3 | import 'express-validator' |
5 | 4 | import * as validator from 'validator' | |
6 | import { database as db } from '../../initializers' | 5 | import { database as db } from '../../initializers' |
7 | import { AccountInstance } from '../../models' | 6 | import { AccountInstance } from '../../models' |
8 | import { logger } from '../logger' | 7 | import { logger } from '../logger' |
9 | |||
10 | import { isUserUsernameValid } from './users' | 8 | import { isUserUsernameValid } from './users' |
11 | import { isHostValid } from './servers' | ||
12 | 9 | ||
13 | function isAccountNameValid (value: string) { | 10 | function isAccountNameValid (value: string) { |
14 | return isUserUsernameValid(value) | 11 | return isUserUsernameValid(value) |
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 | } |