diff options
author | Chocobozzz <me@florianbigard.com> | 2020-12-03 14:10:54 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-12-03 15:21:16 +0100 |
commit | bb4ba6d94c5051fdd665ebe63fffcc105778b8be (patch) | |
tree | d39302608c53e31395683bb5dd551eac6ced89f8 /server/middlewares | |
parent | 19b7ebfaa822b12f6da25ad2ba10398b3ef25ec6 (diff) | |
download | PeerTube-bb4ba6d94c5051fdd665ebe63fffcc105778b8be.tar.gz PeerTube-bb4ba6d94c5051fdd665ebe63fffcc105778b8be.tar.zst PeerTube-bb4ba6d94c5051fdd665ebe63fffcc105778b8be.zip |
Add permanent live support
Diffstat (limited to 'server/middlewares')
-rw-r--r-- | server/middlewares/validators/videos/video-live.ts | 19 |
1 files changed, 18 insertions, 1 deletions
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([ | |||
49 | .customSanitizer(toBooleanOrNull) | 49 | .customSanitizer(toBooleanOrNull) |
50 | .custom(isBooleanValid).withMessage('Should have a valid saveReplay attribute'), | 50 | .custom(isBooleanValid).withMessage('Should have a valid saveReplay attribute'), |
51 | 51 | ||
52 | body('permanentLive') | ||
53 | .optional() | ||
54 | .customSanitizer(toBooleanOrNull) | ||
55 | .custom(isBooleanValid).withMessage('Should have a valid permanentLive attribute'), | ||
56 | |||
52 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | 57 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { |
53 | logger.debug('Checking videoLiveAddValidator parameters', { parameters: req.body }) | 58 | logger.debug('Checking videoLiveAddValidator parameters', { parameters: req.body }) |
54 | 59 | ||
60 | if (areValidationErrors(req, res)) return cleanUpReqFiles(req) | ||
61 | |||
55 | if (CONFIG.LIVE.ENABLED !== true) { | 62 | if (CONFIG.LIVE.ENABLED !== true) { |
56 | cleanUpReqFiles(req) | 63 | cleanUpReqFiles(req) |
57 | 64 | ||
@@ -66,7 +73,12 @@ const videoLiveAddValidator = getCommonVideoEditAttributes().concat([ | |||
66 | .json({ error: 'Saving live replay is not allowed instance' }) | 73 | .json({ error: 'Saving live replay is not allowed instance' }) |
67 | } | 74 | } |
68 | 75 | ||
69 | if (areValidationErrors(req, res)) return cleanUpReqFiles(req) | 76 | if (req.body.permanentLive && req.body.saveReplay) { |
77 | cleanUpReqFiles(req) | ||
78 | |||
79 | return res.status(400) | ||
80 | .json({ error: 'Cannot set this live as permanent while saving its replay' }) | ||
81 | } | ||
70 | 82 | ||
71 | const user = res.locals.oauth.token.User | 83 | const user = res.locals.oauth.token.User |
72 | if (!await doesVideoChannelOfAccountExist(req.body.channelId, user, res)) return cleanUpReqFiles(req) | 84 | if (!await doesVideoChannelOfAccountExist(req.body.channelId, user, res)) return cleanUpReqFiles(req) |
@@ -116,6 +128,11 @@ const videoLiveUpdateValidator = [ | |||
116 | 128 | ||
117 | if (areValidationErrors(req, res)) return | 129 | if (areValidationErrors(req, res)) return |
118 | 130 | ||
131 | if (req.body.permanentLive && req.body.saveReplay) { | ||
132 | return res.status(400) | ||
133 | .json({ error: 'Cannot set this live as permanent while saving its replay' }) | ||
134 | } | ||
135 | |||
119 | if (CONFIG.LIVE.ALLOW_REPLAY !== true && req.body.saveReplay === true) { | 136 | if (CONFIG.LIVE.ALLOW_REPLAY !== true && req.body.saveReplay === true) { |
120 | return res.status(403) | 137 | return res.status(403) |
121 | .json({ error: 'Saving live replay is not allowed instance' }) | 138 | .json({ error: 'Saving live replay is not allowed instance' }) |