From 7ccddd7b5250bd25a917a6e77e58b87b9484a2a4 Mon Sep 17 00:00:00 2001 From: Josh Morel Date: Tue, 2 Apr 2019 05:26:47 -0400 Subject: add quarantine videos feature (#1637) * add quarantine videos feature * increase Notification settings test timeout to 20000ms. was completing 7000 locally but timing out after 10000 on travis * fix quarantine video test issues -propagate misspelling -remove skip from server/tests/client.ts * WIP use blacklist for moderator video approval instead of video.quarantine boolean * finish auto-blacklist feature --- .../validators/videos/video-blacklist.ts | 25 +++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'server/middlewares') diff --git a/server/middlewares/validators/videos/video-blacklist.ts b/server/middlewares/validators/videos/video-blacklist.ts index db318dcdb..1d7ddb2e3 100644 --- a/server/middlewares/validators/videos/video-blacklist.ts +++ b/server/middlewares/validators/videos/video-blacklist.ts @@ -1,10 +1,14 @@ import * as express from 'express' -import { body, param } from 'express-validator/check' +import { body, param, query } from 'express-validator/check' import { isBooleanValid, isIdOrUUIDValid } from '../../../helpers/custom-validators/misc' import { doesVideoExist } from '../../../helpers/custom-validators/videos' import { logger } from '../../../helpers/logger' import { areValidationErrors } from '../utils' -import { doesVideoBlacklistExist, isVideoBlacklistReasonValid } from '../../../helpers/custom-validators/video-blacklist' +import { + doesVideoBlacklistExist, + isVideoBlacklistReasonValid, + isVideoBlacklistTypeValid +} from '../../../helpers/custom-validators/video-blacklist' const videosBlacklistRemoveValidator = [ param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'), @@ -65,10 +69,25 @@ const videosBlacklistUpdateValidator = [ } ] +const videosBlacklistFiltersValidator = [ + query('type') + .optional() + .custom(isVideoBlacklistTypeValid).withMessage('Should have a valid video blacklist type attribute'), + + (req: express.Request, res: express.Response, next: express.NextFunction) => { + logger.debug('Checking videos blacklist filters query', { parameters: req.query }) + + if (areValidationErrors(req, res)) return + + return next() + } +] + // --------------------------------------------------------------------------- export { videosBlacklistAddValidator, videosBlacklistRemoveValidator, - videosBlacklistUpdateValidator + videosBlacklistUpdateValidator, + videosBlacklistFiltersValidator } -- cgit v1.2.3