From c9bc850e93295661e743255b8623ac8e2a95c391 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 15 Dec 2020 09:23:28 +0100 Subject: Use -1 for max live duration unlimited --- server/lib/live-manager.ts | 2 +- server/middlewares/validators/config.ts | 4 ++-- server/tests/api/check-params/config.ts | 2 +- server/tests/api/live/live-permanent.ts | 4 ++-- server/tests/api/live/live-save-replay.ts | 2 +- server/tests/api/live/live.ts | 2 +- server/tests/api/server/config.ts | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) (limited to 'server') diff --git a/server/lib/live-manager.ts b/server/lib/live-manager.ts index 2fb4b774c..379f61bdf 100644 --- a/server/lib/live-manager.ts +++ b/server/lib/live-manager.ts @@ -505,7 +505,7 @@ class LiveManager { private isDurationConstraintValid (streamingStartTime: number) { const maxDuration = CONFIG.LIVE.MAX_DURATION // No limit - if (maxDuration === null) return true + if (maxDuration < 0) return true const now = new Date().getTime() const max = streamingStartTime + maxDuration diff --git a/server/middlewares/validators/config.ts b/server/middlewares/validators/config.ts index 93de453a7..9c1cfa7e7 100644 --- a/server/middlewares/validators/config.ts +++ b/server/middlewares/validators/config.ts @@ -2,13 +2,13 @@ import * as express from 'express' import { body } from 'express-validator' import { isIntOrNull } from '@server/helpers/custom-validators/misc' import { isEmailEnabled } from '@server/initializers/config' +import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' import { CustomConfig } from '../../../shared/models/server/custom-config.model' import { isThemeNameValid } from '../../helpers/custom-validators/plugins' import { isUserNSFWPolicyValid, isUserVideoQuotaDailyValid, isUserVideoQuotaValid } from '../../helpers/custom-validators/users' import { logger } from '../../helpers/logger' import { isThemeRegistered } from '../../lib/plugins/theme-utils' import { areValidationErrors } from './utils' -import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' const customConfigUpdateValidator = [ body('instance.name').exists().withMessage('Should have a valid instance name'), @@ -65,7 +65,7 @@ const customConfigUpdateValidator = [ body('live.enabled').isBoolean().withMessage('Should have a valid live enabled boolean'), body('live.allowReplay').isBoolean().withMessage('Should have a valid live allow replay boolean'), - body('live.maxDuration').custom(isIntOrNull).withMessage('Should have a valid live max duration'), + body('live.maxDuration').isInt().withMessage('Should have a valid live max duration'), body('live.maxInstanceLives').custom(isIntOrNull).withMessage('Should have a valid max instance lives'), body('live.maxUserLives').custom(isIntOrNull).withMessage('Should have a valid max user lives'), body('live.transcoding.enabled').isBoolean().withMessage('Should have a valid live transcoding enabled boolean'), diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.ts index 08576c3ae..fab440fc5 100644 --- a/server/tests/api/check-params/config.ts +++ b/server/tests/api/check-params/config.ts @@ -105,7 +105,7 @@ describe('Test config API validators', function () { enabled: true, allowReplay: false, - maxDuration: null, + maxDuration: 30, maxInstanceLives: -1, maxUserLives: 50, diff --git a/server/tests/api/live/live-permanent.ts b/server/tests/api/live/live-permanent.ts index 9e6c6cf70..1128e993c 100644 --- a/server/tests/api/live/live-permanent.ts +++ b/server/tests/api/live/live-permanent.ts @@ -66,7 +66,7 @@ describe('Permenant live', function () { live: { enabled: true, allowReplay: true, - maxDuration: null, + maxDuration: -1, transcoding: { enabled: true, resolutions: { @@ -155,7 +155,7 @@ describe('Permenant live', function () { live: { enabled: true, allowReplay: true, - maxDuration: null, + maxDuration: -1, transcoding: { enabled: true, resolutions: { diff --git a/server/tests/api/live/live-save-replay.ts b/server/tests/api/live/live-save-replay.ts index 6cd8cc23f..35fe4e7bd 100644 --- a/server/tests/api/live/live-save-replay.ts +++ b/server/tests/api/live/live-save-replay.ts @@ -90,7 +90,7 @@ describe('Save replay setting', function () { live: { enabled: true, allowReplay: true, - maxDuration: null, + maxDuration: -1, transcoding: { enabled: false, resolutions: { diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts index 918792081..939285ae8 100644 --- a/server/tests/api/live/live.ts +++ b/server/tests/api/live/live.ts @@ -348,7 +348,7 @@ describe('Test live', function () { live: { enabled: true, allowReplay: true, - maxDuration: null, + maxDuration: -1, transcoding: { enabled: true, resolutions: { diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.ts index a505b8ede..bfaad3688 100644 --- a/server/tests/api/server/config.ts +++ b/server/tests/api/server/config.ts @@ -81,7 +81,7 @@ function checkInitialConfig (server: ServerInfo, data: CustomConfig) { expect(data.live.enabled).to.be.false expect(data.live.allowReplay).to.be.false - expect(data.live.maxDuration).to.be.null + expect(data.live.maxDuration).to.equal(-1) expect(data.live.maxInstanceLives).to.equal(20) expect(data.live.maxUserLives).to.equal(3) expect(data.live.transcoding.enabled).to.be.false -- cgit v1.2.3