diff options
author | Chocobozzz <me@florianbigard.com> | 2023-07-28 16:11:52 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-07-28 16:17:37 +0200 |
commit | eeb838faf2ac3cb3bd42f68fafb4f78af4547a09 (patch) | |
tree | c814953de92a45a81b159a9d8778581b4fc8a2af /server/middlewares | |
parent | 74c8d5bf2d807870ed351fb2a0ee7137987aa995 (diff) | |
download | PeerTube-eeb838faf2ac3cb3bd42f68fafb4f78af4547a09.tar.gz PeerTube-eeb838faf2ac3cb3bd42f68fafb4f78af4547a09.tar.zst PeerTube-eeb838faf2ac3cb3bd42f68fafb4f78af4547a09.zip |
currentTime is now required
Diffstat (limited to 'server/middlewares')
-rw-r--r-- | server/middlewares/validators/videos/video-view.ts | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/server/middlewares/validators/videos/video-view.ts b/server/middlewares/validators/videos/video-view.ts index 6e2d4505d..a2f61f4ba 100644 --- a/server/middlewares/validators/videos/video-view.ts +++ b/server/middlewares/validators/videos/video-view.ts | |||
@@ -4,7 +4,7 @@ import { isVideoTimeValid } from '@server/helpers/custom-validators/video-view' | |||
4 | import { getCachedVideoDuration } from '@server/lib/video' | 4 | import { getCachedVideoDuration } from '@server/lib/video' |
5 | import { LocalVideoViewerModel } from '@server/models/view/local-video-viewer' | 5 | import { LocalVideoViewerModel } from '@server/models/view/local-video-viewer' |
6 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' | 6 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
7 | import { exists, isIdValid, isIntOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc' | 7 | import { isIdValid, isIntOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc' |
8 | import { areValidationErrors, doesVideoExist, isValidVideoIdParam } from '../shared' | 8 | import { areValidationErrors, doesVideoExist, isValidVideoIdParam } from '../shared' |
9 | 9 | ||
10 | const getVideoLocalViewerValidator = [ | 10 | const getVideoLocalViewerValidator = [ |
@@ -32,7 +32,6 @@ const videoViewValidator = [ | |||
32 | isValidVideoIdParam('videoId'), | 32 | isValidVideoIdParam('videoId'), |
33 | 33 | ||
34 | body('currentTime') | 34 | body('currentTime') |
35 | .optional() // TODO: remove optional in a few versions, introduced in 4.2 | ||
36 | .customSanitizer(toIntOrNull) | 35 | .customSanitizer(toIntOrNull) |
37 | .custom(isIntOrNull), | 36 | .custom(isIntOrNull), |
38 | 37 | ||
@@ -43,13 +42,7 @@ const videoViewValidator = [ | |||
43 | const video = res.locals.onlyImmutableVideo | 42 | const video = res.locals.onlyImmutableVideo |
44 | const { duration } = await getCachedVideoDuration(video.id) | 43 | const { duration } = await getCachedVideoDuration(video.id) |
45 | 44 | ||
46 | if (!exists(req.body.currentTime)) { // TODO: remove in a few versions, introduced in 4.2 | 45 | if (!isVideoTimeValid(req.body.currentTime, duration)) { |
47 | req.body.currentTime = Math.min(duration ?? 0, 30) | ||
48 | } | ||
49 | |||
50 | const currentTime: number = req.body.currentTime | ||
51 | |||
52 | if (!isVideoTimeValid(currentTime, duration)) { | ||
53 | return res.fail({ | 46 | return res.fail({ |
54 | status: HttpStatusCode.BAD_REQUEST_400, | 47 | status: HttpStatusCode.BAD_REQUEST_400, |
55 | message: 'Current time is invalid' | 48 | message: 'Current time is invalid' |