]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/middlewares/validators/config.ts
Add sync link to import page
[github/Chocobozzz/PeerTube.git] / server / middlewares / validators / config.ts
index a44fcb854d7c12c3011da40b0d7b20f7fd2b06f2..f60103f480468e797c765f5a9d1b8624a120449a 100644 (file)
@@ -54,6 +54,9 @@ const customConfigUpdateValidator = [
   body('transcoding.resolutions.1440p').isBoolean().withMessage('Should have a valid transcoding 1440p resolution enabled boolean'),
   body('transcoding.resolutions.2160p').isBoolean().withMessage('Should have a valid transcoding 2160p resolution enabled boolean'),
 
+  body('transcoding.alwaysTranscodeOriginalResolution').isBoolean()
+    .withMessage('Should have a valid always transcode original resolution 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'),
 
@@ -63,6 +66,8 @@ const customConfigUpdateValidator = [
   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'),
 
+  body('import.videoChannelSynchronization.enabled').isBoolean().withMessage('Should have a valid synchronization enabled boolean'),
+
   body('trending.videos.algorithms.default').exists().withMessage('Should have a valid default trending algorithm'),
   body('trending.videos.algorithms.enabled').exists().withMessage('Should have a valid array of enabled trending algorithms'),
 
@@ -91,6 +96,8 @@ const customConfigUpdateValidator = [
   body('live.transcoding.resolutions.1080p').isBoolean().withMessage('Should have a valid transcoding 1080p resolution enabled boolean'),
   body('live.transcoding.resolutions.1440p').isBoolean().withMessage('Should have a valid transcoding 1440p resolution enabled boolean'),
   body('live.transcoding.resolutions.2160p').isBoolean().withMessage('Should have a valid transcoding 2160p resolution enabled boolean'),
+  body('live.transcoding.alwaysTranscodeOriginalResolution').isBoolean()
+    .withMessage('Should have a valid always transcode live original resolution boolean'),
 
   body('search.remoteUri.users').isBoolean().withMessage('Should have a remote URI search for users boolean'),
   body('search.remoteUri.anonymous').isBoolean().withMessage('Should have a valid remote URI search for anonymous boolean'),
@@ -105,6 +112,7 @@ const customConfigUpdateValidator = [
     if (areValidationErrors(req, res)) return
     if (!checkInvalidConfigIfEmailDisabled(req.body, res)) return
     if (!checkInvalidTranscodingConfig(req.body, res)) return
+    if (!checkInvalidSynchronizationConfig(req.body, res)) return
     if (!checkInvalidLiveConfig(req.body, res)) return
     if (!checkInvalidVideoStudioConfig(req.body, res)) return
 
@@ -152,6 +160,14 @@ function checkInvalidTranscodingConfig (customConfig: CustomConfig, res: express
   return true
 }
 
+function checkInvalidSynchronizationConfig (customConfig: CustomConfig, res: express.Response) {
+  if (customConfig.import.videoChannelSynchronization.enabled && !customConfig.import.videos.http.enabled) {
+    res.fail({ message: 'You need to enable HTTP video import in order to enable channel synchronization' })
+    return false
+  }
+  return true
+}
+
 function checkInvalidLiveConfig (customConfig: CustomConfig, res: express.Response) {
   if (customConfig.live.enabled === false) return true