From d4f1e94c89336255537b0b82913591f00e716201 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 23 Nov 2017 18:04:48 +0100 Subject: Misc cleanup --- server/helpers/custom-validators/accounts.ts | 5 +---- server/helpers/custom-validators/videos.ts | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) (limited to 'server/helpers') 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 @@ import * as Promise from 'bluebird' -import * as validator from 'validator' import * as express from 'express' import 'express-validator' - +import * as validator from 'validator' import { database as db } from '../../initializers' import { AccountInstance } from '../../models' import { logger } from '../logger' - import { isUserUsernameValid } from './users' -import { isHostValid } from './servers' function isAccountNameValid (value: string) { 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[] } | return new RegExp('^video/(webm|mp4|ogg)$', 'i').test(file.mimetype) } +function isVideoPrivacyValid (value: string) { + return VIDEO_PRIVACIES[value] !== undefined +} + function isVideoFileInfoHashValid (value: string) { return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.INFO_HASH) } -function isVideoPrivacyValid (value: string) { - return VIDEO_PRIVACIES[value] !== undefined +function isVideoFileResolutionValid (value: string) { + return exists(value) && validator.isInt(value + '') +} + +function isVideoFileSizeValid (value: string) { + return exists(value) && validator.isInt(value + '', VIDEOS_CONSTRAINTS_FIELDS.FILE_SIZE) } function checkVideoExists (id: string, res: Response, callback: () => void) { @@ -142,5 +150,7 @@ export { isVideoTagValid, isVideoUrlValid, isVideoPrivacyValid, + isVideoFileResolutionValid, + isVideoFileSizeValid, checkVideoExists } -- cgit v1.2.3