From 156c50af3085468a47b8ae73fe8cfcae46b42398 Mon Sep 17 00:00:00 2001 From: Lucas Declercq Date: Sat, 6 Oct 2018 19:17:21 +0200 Subject: Add downloadingEnabled property to video model --- server/middlewares/validators/videos/videos.ts | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'server/middlewares') diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts index d6b8aa725..bdba87496 100644 --- a/server/middlewares/validators/videos/videos.ts +++ b/server/middlewares/validators/videos/videos.ts @@ -349,6 +349,10 @@ function getCommonVideoAttributes () { .optional() .toBoolean() .custom(isBooleanValid).withMessage('Should have comments enabled boolean'), + body('downloadingEnabled') + .optional() + .toBoolean() + .custom(isBooleanValid).withMessage('Should have downloading enabled boolean'), body('scheduleUpdate') .optional() -- cgit v1.2.3 From 7f2cfe3a792856f7de6f1d13688aa3d06ec1bf70 Mon Sep 17 00:00:00 2001 From: Lucas Declercq Date: Mon, 8 Oct 2018 14:45:22 +0200 Subject: Rename downloadingEnabled property to downloadEnabled --- server/middlewares/validators/videos/videos.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'server/middlewares') diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts index bdba87496..27e8a7449 100644 --- a/server/middlewares/validators/videos/videos.ts +++ b/server/middlewares/validators/videos/videos.ts @@ -349,7 +349,7 @@ function getCommonVideoAttributes () { .optional() .toBoolean() .custom(isBooleanValid).withMessage('Should have comments enabled boolean'), - body('downloadingEnabled') + body('downloadEnabled') .optional() .toBoolean() .custom(isBooleanValid).withMessage('Should have downloading enabled boolean'), -- cgit v1.2.3 From 5abb9fbbd12e7097e348d6a38622d364b1fa47ed Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 10 Jan 2019 15:39:51 +0100 Subject: Add ability to unfederate a local video (on blacklist) --- server/middlewares/validators/videos/video-blacklist.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'server/middlewares') diff --git a/server/middlewares/validators/videos/video-blacklist.ts b/server/middlewares/validators/videos/video-blacklist.ts index 13da7acff..2688f63ae 100644 --- a/server/middlewares/validators/videos/video-blacklist.ts +++ b/server/middlewares/validators/videos/video-blacklist.ts @@ -1,10 +1,11 @@ import * as express from 'express' import { body, param } from 'express-validator/check' -import { isIdOrUUIDValid } from '../../../helpers/custom-validators/misc' +import { isBooleanValid, isIdOrUUIDValid } from '../../../helpers/custom-validators/misc' import { isVideoExist } from '../../../helpers/custom-validators/videos' import { logger } from '../../../helpers/logger' import { areValidationErrors } from '../utils' import { isVideoBlacklistExist, isVideoBlacklistReasonValid } from '../../../helpers/custom-validators/video-blacklist' +import { VideoModel } from '../../../models/video/video' const videosBlacklistRemoveValidator = [ param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'), @@ -22,6 +23,10 @@ const videosBlacklistRemoveValidator = [ const videosBlacklistAddValidator = [ param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'), + body('unfederate') + .optional() + .toBoolean() + .custom(isBooleanValid).withMessage('Should have a valid unfederate boolean'), body('reason') .optional() .custom(isVideoBlacklistReasonValid).withMessage('Should have a valid reason'), @@ -32,6 +37,14 @@ const videosBlacklistAddValidator = [ if (areValidationErrors(req, res)) return if (!await isVideoExist(req.params.videoId, res)) return + const video: VideoModel = res.locals.video + if (req.body.unfederate === true && video.remote === true) { + return res + .status(409) + .send({ error: 'You cannot unfederate a remote video.' }) + .end() + } + return next() } ] -- cgit v1.2.3 From 2adfc7ea9a1f858db874df9fe322e7ae833db77c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 23 Jan 2019 15:36:45 +0100 Subject: Refractor videojs player Add fake p2p-media-loader plugin --- server/middlewares/csp.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'server/middlewares') diff --git a/server/middlewares/csp.ts b/server/middlewares/csp.ts index 8b919af0d..5fa9d1ab5 100644 --- a/server/middlewares/csp.ts +++ b/server/middlewares/csp.ts @@ -16,7 +16,7 @@ const baseDirectives = Object.assign({}, baseUri: ["'self'"], manifestSrc: ["'self'"], frameSrc: ["'self'"], // instead of deprecated child-src / self because of test-embed - workerSrc: ["'self'"] // instead of deprecated child-src + workerSrc: ["'self'", 'blob:'] // instead of deprecated child-src }, CONFIG.SERVICES['CSP-LOGGER'] ? { reportUri: CONFIG.SERVICES['CSP-LOGGER'] } : {}, CONFIG.WEBSERVER.SCHEME === 'https' ? { upgradeInsecureRequests: true } : {} -- cgit v1.2.3 From 092092969633bbcf6d4891a083ea497a7d5c3154 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 29 Jan 2019 08:37:25 +0100 Subject: Add hls support on server --- server/middlewares/validators/redundancy.ts | 33 +++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'server/middlewares') diff --git a/server/middlewares/validators/redundancy.ts b/server/middlewares/validators/redundancy.ts index c72ab78b2..329322509 100644 --- a/server/middlewares/validators/redundancy.ts +++ b/server/middlewares/validators/redundancy.ts @@ -13,7 +13,7 @@ import { ActorFollowModel } from '../../models/activitypub/actor-follow' import { SERVER_ACTOR_NAME } from '../../initializers' import { ServerModel } from '../../models/server/server' -const videoRedundancyGetValidator = [ +const videoFileRedundancyGetValidator = [ param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid video id'), param('resolution') .customSanitizer(toIntOrNull) @@ -24,7 +24,7 @@ const videoRedundancyGetValidator = [ .custom(exists).withMessage('Should have a valid fps'), async (req: express.Request, res: express.Response, next: express.NextFunction) => { - logger.debug('Checking videoRedundancyGetValidator parameters', { parameters: req.params }) + logger.debug('Checking videoFileRedundancyGetValidator parameters', { parameters: req.params }) if (areValidationErrors(req, res)) return if (!await isVideoExist(req.params.videoId, res)) return @@ -38,7 +38,31 @@ const videoRedundancyGetValidator = [ res.locals.videoFile = videoFile const videoRedundancy = await VideoRedundancyModel.loadLocalByFileId(videoFile.id) - if (!videoRedundancy)return res.status(404).json({ error: 'Video redundancy not found.' }) + if (!videoRedundancy) return res.status(404).json({ error: 'Video redundancy not found.' }) + res.locals.videoRedundancy = videoRedundancy + + return next() + } +] + +const videoPlaylistRedundancyGetValidator = [ + param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid video id'), + param('streamingPlaylistType').custom(exists).withMessage('Should have a valid streaming playlist type'), + + async (req: express.Request, res: express.Response, next: express.NextFunction) => { + logger.debug('Checking videoPlaylistRedundancyGetValidator parameters', { parameters: req.params }) + + if (areValidationErrors(req, res)) return + if (!await isVideoExist(req.params.videoId, res)) return + + const video: VideoModel = res.locals.video + const videoStreamingPlaylist = video.VideoStreamingPlaylists.find(p => p === req.params.streamingPlaylistType) + + if (!videoStreamingPlaylist) return res.status(404).json({ error: 'Video playlist not found.' }) + res.locals.videoStreamingPlaylist = videoStreamingPlaylist + + const videoRedundancy = await VideoRedundancyModel.loadLocalByStreamingPlaylistId(videoStreamingPlaylist.id) + if (!videoRedundancy) return res.status(404).json({ error: 'Video redundancy not found.' }) res.locals.videoRedundancy = videoRedundancy return next() @@ -75,6 +99,7 @@ const updateServerRedundancyValidator = [ // --------------------------------------------------------------------------- export { - videoRedundancyGetValidator, + videoFileRedundancyGetValidator, + videoPlaylistRedundancyGetValidator, updateServerRedundancyValidator } -- cgit v1.2.3 From b426edd4854adc6e65844d8c54b8998e792b5778 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 11 Feb 2019 09:30:29 +0100 Subject: Cleanup reset user password by admin And add some tests --- server/middlewares/validators/users.ts | 2 ++ 1 file changed, 2 insertions(+) (limited to 'server/middlewares') diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts index 1bb0bfb1b..a52e3060a 100644 --- a/server/middlewares/validators/users.ts +++ b/server/middlewares/validators/users.ts @@ -113,6 +113,7 @@ const deleteMeValidator = [ const usersUpdateValidator = [ param('id').isInt().not().isEmpty().withMessage('Should have a valid id'), + body('password').optional().custom(isUserPasswordValid).withMessage('Should have a valid password'), body('email').optional().isEmail().withMessage('Should have a valid email attribute'), body('emailVerified').optional().isBoolean().withMessage('Should have a valid email verified attribute'), body('videoQuota').optional().custom(isUserVideoQuotaValid).withMessage('Should have a valid user quota'), @@ -233,6 +234,7 @@ const usersAskResetPasswordValidator = [ logger.debug('Checking usersAskResetPassword parameters', { parameters: req.body }) if (areValidationErrors(req, res)) return + const exists = await checkUserEmailExist(req.body.email, res, false) if (!exists) { logger.debug('User with email %s does not exist (asking reset password).', req.body.email) -- cgit v1.2.3