X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmiddlewares%2Fvalidators%2Fvideos%2Fvideo-view.ts;h=6e2d4505d9bab43ef4dda175e9d7650a0d1a1c2f;hb=cb0eda5602a21d1626a7face32de6153ed07b5f9;hp=2edcd140f7cc13b368fbca37d1fbc9d8ad81f049;hpb=a2fb5fb8b1007e3ce82e707917f5d9a37374e99b;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/middlewares/validators/videos/video-view.ts b/server/middlewares/validators/videos/video-view.ts index 2edcd140f..6e2d4505d 100644 --- a/server/middlewares/validators/videos/video-view.ts +++ b/server/middlewares/validators/videos/video-view.ts @@ -1,20 +1,17 @@ import express from 'express' import { body, param } from 'express-validator' import { isVideoTimeValid } from '@server/helpers/custom-validators/video-view' +import { getCachedVideoDuration } from '@server/lib/video' import { LocalVideoViewerModel } from '@server/models/view/local-video-viewer' import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' import { exists, isIdValid, isIntOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc' -import { logger } from '../../../helpers/logger' import { areValidationErrors, doesVideoExist, isValidVideoIdParam } from '../shared' -import { getCachedVideoDuration } from '@server/lib/video' const getVideoLocalViewerValidator = [ param('localViewerId') - .custom(isIdValid).withMessage('Should have a valid local viewer id'), + .custom(isIdValid), async (req: express.Request, res: express.Response, next: express.NextFunction) => { - logger.debug('Checking getVideoLocalViewerValidator parameters', { parameters: req.params }) - if (areValidationErrors(req, res)) return const localViewer = await LocalVideoViewerModel.loadFullById(+req.params.localViewerId) @@ -37,11 +34,9 @@ const videoViewValidator = [ body('currentTime') .optional() // TODO: remove optional in a few versions, introduced in 4.2 .customSanitizer(toIntOrNull) - .custom(isIntOrNull).withMessage('Should have correct current time'), + .custom(isIntOrNull), async (req: express.Request, res: express.Response, next: express.NextFunction) => { - logger.debug('Checking videoView parameters', { parameters: req.body }) - if (areValidationErrors(req, res)) return if (!await doesVideoExist(req.params.videoId, res, 'only-immutable-attributes')) return