diff --git a/packages/tests/src/api/check-params/views.ts b/packages/tests/src/api/check-params/views.ts index 2d3159eab..69f8ffc6e 100644 --- a/packages/tests/src/api/check-params/views.ts +++ b/packages/tests/src/api/check-params/views.ts @@ -48,6 +48,7 @@ describe('Test videos views', function () { }) it('Should fail with an invalid current time', async function () { + await servers[0].views.view({ id: videoId, currentTime: null, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) await servers[0].views.view({ id: videoId, currentTime: -1, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) await servers[0].views.view({ id: videoId, currentTime: 10, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) }) diff --git a/server/core/middlewares/validators/videos/video-view.ts b/server/core/middlewares/validators/videos/video-view.ts index 14ee1da46..3ccb9ba1f 100644 --- a/server/core/middlewares/validators/videos/video-view.ts +++ b/server/core/middlewares/validators/videos/video-view.ts @@ -4,7 +4,7 @@ import { HttpStatusCode } from '@peertube/peertube-models' import { isVideoTimeValid } from '@server/helpers/custom-validators/video-view.js' import { getCachedVideoDuration } from '@server/lib/video.js' import { LocalVideoViewerModel } from '@server/models/view/local-video-viewer.js' -import { isIdValid, isIntOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc.js' +import { isIdValid, toIntOrNull } from '../../../helpers/custom-validators/misc.js' import { areValidationErrors, doesVideoExist, isValidVideoIdParam } from '../shared/index.js' const getVideoLocalViewerValidator = [ @@ -33,7 +33,7 @@ const videoViewValidator = [ body('currentTime') .customSanitizer(toIntOrNull) - .custom(isIntOrNull), + .isInt(), async (req: express.Request, res: express.Response, next: express.NextFunction) => { if (areValidationErrors(req, res)) return