]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/middlewares/validators/redundancy.ts
Feature/Add replay privacy (#5692)
[github/Chocobozzz/PeerTube.git] / server / middlewares / validators / redundancy.ts
index a74772bd198c9ca26d5f96393f6c3750ca1e4aba..c80f9b728251e214e931d778b49bdad4a90bf166 100644 (file)
@@ -1,6 +1,7 @@
 import express from 'express'
 import { body, param, query } from 'express-validator'
 import { isVideoRedundancyTarget } from '@server/helpers/custom-validators/video-redundancies'
+import { forceNumber } from '@shared/core-utils'
 import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
 import {
   exists,
@@ -12,7 +13,6 @@ import {
   toIntOrNull
 } from '../../helpers/custom-validators/misc'
 import { isHostValid } from '../../helpers/custom-validators/servers'
-import { logger } from '../../helpers/logger'
 import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy'
 import { ServerModel } from '../../models/server/server'
 import { areValidationErrors, doesVideoExist, isValidVideoIdParam } from './shared'
@@ -29,8 +29,6 @@ const videoFileRedundancyGetValidator = [
     .custom(exists),
 
   async (req: express.Request, res: express.Response, next: express.NextFunction) => {
-    logger.debug('Checking videoFileRedundancyGetValidator parameters', { parameters: req.params })
-
     if (areValidationErrors(req, res)) return
     if (!await doesVideoExist(req.params.videoId, res)) return
 
@@ -72,8 +70,6 @@ const videoPlaylistRedundancyGetValidator = [
     .custom(exists),
 
   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 doesVideoExist(req.params.videoId, res)) return
 
@@ -112,8 +108,6 @@ const updateServerRedundancyValidator = [
     .custom(isBooleanValid).withMessage('Should have a valid redundancyAllowed boolean'),
 
   async (req: express.Request, res: express.Response, next: express.NextFunction) => {
-    logger.debug('Checking updateServerRedundancy parameters', { parameters: req.params })
-
     if (areValidationErrors(req, res)) return
 
     const server = await ServerModel.loadByHost(req.params.host)
@@ -135,8 +129,6 @@ const listVideoRedundanciesValidator = [
     .custom(isVideoRedundancyTarget),
 
   (req: express.Request, res: express.Response, next: express.NextFunction) => {
-    logger.debug('Checking listVideoRedundanciesValidator parameters', { parameters: req.query })
-
     if (areValidationErrors(req, res)) return
 
     return next()
@@ -149,8 +141,6 @@ const addVideoRedundancyValidator = [
     .custom(isIdOrUUIDValid),
 
   async (req: express.Request, res: express.Response, next: express.NextFunction) => {
-    logger.debug('Checking addVideoRedundancyValidator parameters', { parameters: req.query })
-
     if (areValidationErrors(req, res)) return
 
     if (!await doesVideoExist(req.body.videoId, res, 'only-video')) return
@@ -180,11 +170,9 @@ const removeVideoRedundancyValidator = [
     .custom(isIdValid),
 
   async (req: express.Request, res: express.Response, next: express.NextFunction) => {
-    logger.debug('Checking removeVideoRedundancyValidator parameters', { parameters: req.query })
-
     if (areValidationErrors(req, res)) return
 
-    const redundancy = await VideoRedundancyModel.loadByIdWithVideo(parseInt(req.params.redundancyId, 10))
+    const redundancy = await VideoRedundancyModel.loadByIdWithVideo(forceNumber(req.params.redundancyId))
     if (!redundancy) {
       return res.fail({
         status: HttpStatusCode.NOT_FOUND_404,