ActivityPub-federated video streaming platform using P2P directly in your web browser
currentTime is now required
Chocobozzzeeb838faf2ac
diff --git a/server/controllers/tracker.ts b/server/controllers/tracker.tsindex 53eab73ac9..9a8aa88bcb 100644--- a/server/controllers/tracker.ts+++ b/server/controllers/tracker.ts@@ -114,8 +114,7 @@ function createWebsocketTrackerServer (app: express.Application) {return}- // FIXME: typings- return wss.handleUpgrade(request, socket as any, head, ws => wss.emit('connection', ws, request))+ return wss.handleUpgrade(request, socket, head, ws => wss.emit('connection', ws, request))}// Don't destroy socket, we have Socket.IO toodiff --git a/server/middlewares/validators/videos/video-view.ts b/server/middlewares/validators/videos/video-view.tsindex 6e2d4505d9..a2f61f4ba3 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'import { getCachedVideoDuration } from '@server/lib/video'import { LocalVideoViewerModel } from '@server/models/view/local-video-viewer'import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'-import { exists, isIdValid, isIntOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc'+import { isIdValid, isIntOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc'import { areValidationErrors, doesVideoExist, isValidVideoIdParam } from '../shared'const getVideoLocalViewerValidator = [@@ -32,7 +32,6 @@ const videoViewValidator = [isValidVideoIdParam('videoId'),body('currentTime')- .optional() // TODO: remove optional in a few versions, introduced in 4.2.customSanitizer(toIntOrNull).custom(isIntOrNull),@@ -43,13 +42,7 @@ const videoViewValidator = [const video = res.locals.onlyImmutableVideoconst { duration } = await getCachedVideoDuration(video.id)- if (!exists(req.body.currentTime)) { // TODO: remove in a few versions, introduced in 4.2- req.body.currentTime = Math.min(duration ?? 0, 30)- }-- const currentTime: number = req.body.currentTime-- if (!isVideoTimeValid(currentTime, duration)) {+ if (!isVideoTimeValid(req.body.currentTime, duration)) {return res.fail({status: HttpStatusCode.BAD_REQUEST_400,message: 'Current time is invalid'diff --git a/server/tests/api/check-params/views.ts b/server/tests/api/check-params/views.tsindex 84d31c5094..11416ccb8c 100644--- a/server/tests/api/check-params/views.ts+++ b/server/tests/api/check-params/views.ts@@ -43,8 +43,9 @@ describe('Test videos views', function () {describe('When viewing a video', async function () {- // TODO: implement it when we'll remove backward compatibility in REST API- it('Should fail without current time')+ it('Should fail without current time', async function () {+ await servers[0].views.view({ id: videoId, currentTime: undefined, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })+ })it('Should fail with an invalid current time', async function () {await servers[0].views.view({ id: videoId, currentTime: -1, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })diff --git a/server/tests/api/videos/videos-common-filters.ts b/server/tests/api/videos/videos-common-filters.tsindex f68560b06c..fac0f5dc56 100644--- a/server/tests/api/videos/videos-common-filters.ts+++ b/server/tests/api/videos/videos-common-filters.ts@@ -546,7 +546,7 @@ describe('Test videos filter', function () {expect(foundVideo).to.not.be.undefined}- await servers[0].views.view({ id, token: servers[0].accessToken })+ await servers[0].views.view({ id, currentTime: 1, token: servers[0].accessToken })for (const path of paths) {const videos = await listVideos({ server: servers[0], path, excludeAlreadyWatched: true })diff --git a/shared/server-commands/videos/views-command.ts b/shared/server-commands/videos/views-command.tsindex 01113f7982..bdb8daaa4d 100644--- a/shared/server-commands/videos/views-command.ts+++ b/shared/server-commands/videos/views-command.ts@@ -6,7 +6,7 @@ export class ViewsCommand extends AbstractCommand {view (options: OverrideCommandOptions & {id: number | string- currentTime?: number+ currentTime: numberviewEvent?: VideoViewEventxForwardedFor?: string}) {@@ -19,7 +19,7 @@ export class ViewsCommand extends AbstractCommand {path,xForwardedFor,fields: {- currentTime: currentTime ?? 1,+ currentTime,viewEvent},implicitToken: false,