]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - shared/extra-utils/server/config-command.ts
Merge branch 'release/4.0.0' into develop
[github/Chocobozzz/PeerTube.git] / shared / extra-utils / server / config-command.ts
index 6e875fdf6030bfafc3b5eccc7d7f96618b146f4b..a061ca89e8e239523a5b8a85495d8affa96fed44 100644 (file)
@@ -1,6 +1,6 @@
 import { merge } from 'lodash'
 import { DeepPartial } from '@shared/core-utils'
-import { About, ServerConfig, HttpStatusCode } from '@shared/models'
+import { About, HttpStatusCode, ServerConfig } from '@shared/models'
 import { CustomConfig } from '../../models/server/custom-config.model'
 import { AbstractCommand, OverrideCommandOptions } from '../shared'
 
@@ -8,6 +8,7 @@ export class ConfigCommand extends AbstractCommand {
 
   static getCustomConfigResolutions (enabled: boolean) {
     return {
+      '144p': enabled,
       '240p': enabled,
       '360p': enabled,
       '480p': enabled,
@@ -18,6 +19,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 +146,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>
   }) {
@@ -121,6 +194,18 @@ export class ConfigCommand extends AbstractCommand {
           whitelisted: true
         }
       },
+      client: {
+        videos: {
+          miniature: {
+            preferAuthorDisplayName: false
+          }
+        },
+        menu: {
+          login: {
+            redirectOnSingleExternalAuth: false
+          }
+        }
+      },
       cache: {
         previews: {
           size: 2
@@ -148,6 +233,9 @@ export class ConfigCommand extends AbstractCommand {
         videoQuota: 5242881,
         videoQuotaDaily: 318742
       },
+      videoChannels: {
+        maxPerUser: 20
+      },
       transcoding: {
         enabled: true,
         allowAdditionalExtensions: true,
@@ -157,6 +245,7 @@ export class ConfigCommand extends AbstractCommand {
         profile: 'default',
         resolutions: {
           '0p': false,
+          '144p': false,
           '240p': false,
           '360p': true,
           '480p': true,
@@ -183,6 +272,7 @@ export class ConfigCommand extends AbstractCommand {
           threads: 4,
           profile: 'default',
           resolutions: {
+            '144p': true,
             '240p': true,
             '360p': true,
             '480p': true,