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 { areValidationErrors } from './shared'
const customConfigUpdateValidator = [
body('instance.name').exists().withMessage('Should have a valid instance name'),
body('cache.previews.size').isInt().withMessage('Should have a valid previews cache size'),
body('cache.captions.size').isInt().withMessage('Should have a valid captions cache size'),
+ body('cache.torrents.size').isInt().withMessage('Should have a valid torrents cache size'),
body('signup.enabled').isBoolean().withMessage('Should have a valid signup enabled boolean'),
body('signup.limit').isInt().withMessage('Should have a valid signup limit'),
body('signup.requiresEmailVerification').isBoolean().withMessage('Should have a valid requiresEmailVerification boolean'),
+ body('signup.minimumAge').isInt().withMessage("Should have a valid minimum age required"),
body('admin.email').isEmail().withMessage('Should have a valid administrator email'),
body('contactForm.enabled').isBoolean().withMessage('Should have a valid contact form enabled boolean'),
body('transcoding.enabled').isBoolean().withMessage('Should have a valid transcoding enabled boolean'),
body('transcoding.allowAdditionalExtensions').isBoolean().withMessage('Should have a valid additional extensions boolean'),
body('transcoding.threads').isInt().withMessage('Should have a valid transcoding threads number'),
+ body('transcoding.concurrency').isInt({ min: 1 }).withMessage('Should have a valid transcoding concurrency number'),
body('transcoding.resolutions.0p').isBoolean().withMessage('Should have a valid transcoding 0p resolution enabled boolean'),
body('transcoding.resolutions.240p').isBoolean().withMessage('Should have a valid transcoding 240p resolution enabled boolean'),
body('transcoding.resolutions.360p').isBoolean().withMessage('Should have a valid transcoding 360p resolution enabled boolean'),
body('transcoding.webtorrent.enabled').isBoolean().withMessage('Should have a valid webtorrent transcoding enabled boolean'),
body('transcoding.hls.enabled').isBoolean().withMessage('Should have a valid hls transcoding enabled boolean'),
+ body('import.videos.concurrency').isInt({ min: 0 }).withMessage('Should have a valid import concurrency number'),
body('import.videos.http.enabled').isBoolean().withMessage('Should have a valid import video http enabled boolean'),
body('import.videos.torrent.enabled').isBoolean().withMessage('Should have a valid import video torrent enabled boolean'),
if (isEmailEnabled()) return true
if (customConfig.signup.requiresEmailVerification === true) {
- res.status(HttpStatusCode.BAD_REQUEST_400)
- .send({ error: 'Emailer is disabled but you require signup email verification.' })
- .end()
+ res.fail({ message: 'Emailer is disabled but you require signup email verification.' })
return false
}
if (customConfig.transcoding.enabled === false) return true
if (customConfig.transcoding.webtorrent.enabled === false && customConfig.transcoding.hls.enabled === false) {
- res.status(HttpStatusCode.BAD_REQUEST_400)
- .send({ error: 'You need to enable at least webtorrent transcoding or hls transcoding' })
- .end()
+ res.fail({ message: 'You need to enable at least webtorrent transcoding or hls transcoding' })
return false
}
if (customConfig.live.enabled === false) return true
if (customConfig.live.allowReplay === true && customConfig.transcoding.enabled === false) {
- res.status(HttpStatusCode.BAD_REQUEST_400)
- .send({ error: 'You cannot allow live replay if transcoding is not enabled' })
- .end()
+ res.fail({ message: 'You cannot allow live replay if transcoding is not enabled' })
return false
}