1
0
Fork 0

Current time cannot be null

This commit is contained in:
Chocobozzz 2023-12-20 16:07:48 +01:00
parent f0b8938a80
commit 640bc1a0cd
No known key found for this signature in database
GPG key ID: 583A612D890159BE
2 changed files with 3 additions and 2 deletions

View file

@ -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 })
})

View file

@ -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