From bb4ba6d94c5051fdd665ebe63fffcc105778b8be Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 3 Dec 2020 14:10:54 +0100 Subject: Add permanent live support --- server/middlewares/validators/videos/video-live.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'server/middlewares/validators/videos') diff --git a/server/middlewares/validators/videos/video-live.ts b/server/middlewares/validators/videos/video-live.ts index ff92db910..69a14ccb1 100644 --- a/server/middlewares/validators/videos/video-live.ts +++ b/server/middlewares/validators/videos/video-live.ts @@ -49,9 +49,16 @@ const videoLiveAddValidator = getCommonVideoEditAttributes().concat([ .customSanitizer(toBooleanOrNull) .custom(isBooleanValid).withMessage('Should have a valid saveReplay attribute'), + body('permanentLive') + .optional() + .customSanitizer(toBooleanOrNull) + .custom(isBooleanValid).withMessage('Should have a valid permanentLive attribute'), + async (req: express.Request, res: express.Response, next: express.NextFunction) => { logger.debug('Checking videoLiveAddValidator parameters', { parameters: req.body }) + if (areValidationErrors(req, res)) return cleanUpReqFiles(req) + if (CONFIG.LIVE.ENABLED !== true) { cleanUpReqFiles(req) @@ -66,7 +73,12 @@ const videoLiveAddValidator = getCommonVideoEditAttributes().concat([ .json({ error: 'Saving live replay is not allowed instance' }) } - if (areValidationErrors(req, res)) return cleanUpReqFiles(req) + if (req.body.permanentLive && req.body.saveReplay) { + cleanUpReqFiles(req) + + return res.status(400) + .json({ error: 'Cannot set this live as permanent while saving its replay' }) + } const user = res.locals.oauth.token.User if (!await doesVideoChannelOfAccountExist(req.body.channelId, user, res)) return cleanUpReqFiles(req) @@ -116,6 +128,11 @@ const videoLiveUpdateValidator = [ if (areValidationErrors(req, res)) return + if (req.body.permanentLive && req.body.saveReplay) { + return res.status(400) + .json({ error: 'Cannot set this live as permanent while saving its replay' }) + } + if (CONFIG.LIVE.ALLOW_REPLAY !== true && req.body.saveReplay === true) { return res.status(403) .json({ error: 'Saving live replay is not allowed instance' }) -- cgit v1.2.3