]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/middlewares/validators/redundancy.ts
Type toActivityPubObject functions
[github/Chocobozzz/PeerTube.git] / server / middlewares / validators / redundancy.ts
index edc53a6b268552d47155bce1fe9d30563ff538de..e65d3b8d3d874c4495f3e11e1f2890e19e307cc1 100644 (file)
@@ -1,7 +1,6 @@
 import * as express from 'express'
-import 'express-validator'
-import { body, param } from 'express-validator/check'
-import { exists, isBooleanValid, isIdOrUUIDValid, toIntOrNull } from '../../helpers/custom-validators/misc'
+import { body, param } from 'express-validator'
+import { exists, isBooleanValid, isIdOrUUIDValid, toBooleanOrNull, toIntOrNull } from '../../helpers/custom-validators/misc'
 import { logger } from '../../helpers/logger'
 import { areValidationErrors } from './utils'
 import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy'
@@ -25,7 +24,7 @@ const videoFileRedundancyGetValidator = [
     if (areValidationErrors(req, res)) return
     if (!await doesVideoExist(req.params.videoId, res)) return
 
-    const video = res.locals.video
+    const video = res.locals.videoAll
     const videoFile = video.VideoFiles.find(f => {
       return f.resolution === req.params.resolution && (!req.params.fps || f.fps === req.params.fps)
     })
@@ -51,7 +50,7 @@ const videoPlaylistRedundancyGetValidator = [
     if (areValidationErrors(req, res)) return
     if (!await doesVideoExist(req.params.videoId, res)) return
 
-    const video = res.locals.video
+    const video = res.locals.videoAll
     const videoStreamingPlaylist = video.VideoStreamingPlaylists.find(p => p === req.params.streamingPlaylistType)
 
     if (!videoStreamingPlaylist) return res.status(404).json({ error: 'Video playlist not found.' })
@@ -68,7 +67,7 @@ const videoPlaylistRedundancyGetValidator = [
 const updateServerRedundancyValidator = [
   param('host').custom(isHostValid).withMessage('Should have a valid host'),
   body('redundancyAllowed')
-    .toBoolean()
+    .customSanitizer(toBooleanOrNull)
     .custom(isBooleanValid).withMessage('Should have a valid redundancyAllowed attribute'),
 
   async (req: express.Request, res: express.Response, next: express.NextFunction) => {