]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - shared/extra-utils/server/config-command.ts
Rename jobs list command
[github/Chocobozzz/PeerTube.git] / shared / extra-utils / server / config-command.ts
index 11148aa4665e986feef325be082df268ea4c0909..51d04fa63891a05a5ed9e0a4b7f7c69bf4467f70 100644 (file)
@@ -18,6 +18,70 @@ export class ConfigCommand extends AbstractCommand {
     }
   }
 
+  enableImports () {
+    return this.updateExistingSubConfig({
+      newConfig: {
+        import: {
+          videos: {
+            http: {
+              enabled: true
+            },
+
+            torrent: {
+              enabled: true
+            }
+          }
+        }
+      }
+    })
+  }
+
+  enableLive (options: {
+    allowReplay?: boolean
+    transcoding?: boolean
+  } = {}) {
+    return this.updateExistingSubConfig({
+      newConfig: {
+        live: {
+          enabled: true,
+          allowReplay: options.allowReplay ?? true,
+          transcoding: {
+            enabled: options.transcoding ?? true,
+            resolutions: ConfigCommand.getCustomConfigResolutions(true)
+          }
+        }
+      }
+    })
+  }
+
+  disableTranscoding () {
+    return this.updateExistingSubConfig({
+      newConfig: {
+        transcoding: {
+          enabled: false
+        }
+      }
+    })
+  }
+
+  enableTranscoding (webtorrent = true, hls = true) {
+    return this.updateExistingSubConfig({
+      newConfig: {
+        transcoding: {
+          enabled: true,
+          resolutions: ConfigCommand.getCustomConfigResolutions(true),
+
+          webtorrent: {
+            enabled: webtorrent
+          },
+          hls: {
+            enabled: hls
+          }
+        }
+      }
+    })
+  }
+
   getConfig (options: OverrideCommandOptions = {}) {
     const path = '/api/v1/config'
 
@@ -81,6 +145,14 @@ export class ConfigCommand extends AbstractCommand {
     })
   }
 
+  async updateExistingSubConfig (options: OverrideCommandOptions & {
+    newConfig: DeepPartial<CustomConfig>
+  }) {
+    const existing = await this.getCustomConfig(options)
+
+    return this.updateCustomConfig({ ...options, newCustomConfig: merge({}, existing, options.newConfig) })
+  }
+
   updateCustomSubConfig (options: OverrideCommandOptions & {
     newConfig: DeepPartial<CustomConfig>
   }) {