1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 02:39:33 +02:00

fix(server/video-view): log invalid currentTime req (#6288)

* fix(server/video-view): log invalid currentTime req

relates to #6285

* Styling

---------

Co-authored-by: Chocobozzz <me@florianbigard.com>
This commit is contained in:
kontrollanten 2024-03-26 17:08:15 +01:00 committed by GitHub
parent 855def80f6
commit 26de1467e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 11 deletions

View file

@ -1,9 +1,9 @@
import express from 'express'
import { body, param } from 'express-validator'
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 express from 'express'
import { body, param } from 'express-validator'
import { isIdValid, toIntOrNull } from '../../../helpers/custom-validators/misc.js'
import { areValidationErrors, doesVideoExist, isValidVideoIdParam } from '../shared/index.js'
@ -42,10 +42,12 @@ const videoViewValidator = [
const video = res.locals.onlyImmutableVideo
const { duration } = await getCachedVideoDuration(video.id)
if (!isVideoTimeValid(req.body.currentTime, duration)) {
const currentTime = req.body.currentTime
if (!isVideoTimeValid(currentTime, duration)) {
return res.fail({
status: HttpStatusCode.BAD_REQUEST_400,
message: 'Current time is invalid'
message: `Current time ${currentTime} is invalid (video ${video.uuid} duration: ${duration})`,
logLevel: 'warn'
})
}
@ -56,6 +58,6 @@ const videoViewValidator = [
// ---------------------------------------------------------------------------
export {
videoViewValidator,
getVideoLocalViewerValidator
getVideoLocalViewerValidator, videoViewValidator
}