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