]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - shared/server-commands/server/config-command.ts
Translated using Weblate (Persian)
[github/Chocobozzz/PeerTube.git] / shared / server-commands / server / config-command.ts
index 5320dead4705bfe42cbba88d944ce33e1a4174f8..b94bd2625a9cefea6b01def9c5a20c32f90d03e6 100644 (file)
@@ -5,8 +5,9 @@ import { AbstractCommand, OverrideCommandOptions } from '../shared/abstract-comm
 
 export class ConfigCommand extends AbstractCommand {
 
-  static getCustomConfigResolutions (enabled: boolean) {
+  static getCustomConfigResolutions (enabled: boolean, with0p = false) {
     return {
+      '0p': enabled && with0p,
       '144p': enabled,
       '240p': enabled,
       '360p': enabled,
@@ -18,17 +19,52 @@ export class ConfigCommand extends AbstractCommand {
     }
   }
 
+  // ---------------------------------------------------------------------------
+
+  static getEmailOverrideConfig (emailPort: number) {
+    return {
+      smtp: {
+        hostname: '127.0.0.1',
+        port: emailPort
+      }
+    }
+  }
+
+  // ---------------------------------------------------------------------------
+
+  enableSignup (requiresApproval: boolean, limit = -1) {
+    return this.updateExistingSubConfig({
+      newConfig: {
+        signup: {
+          enabled: true,
+          requiresApproval,
+          limit
+        }
+      }
+    })
+  }
+
+  // ---------------------------------------------------------------------------
+
+  disableImports () {
+    return this.setImportsEnabled(false)
+  }
+
   enableImports () {
+    return this.setImportsEnabled(true)
+  }
+
+  private setImportsEnabled (enabled: boolean) {
     return this.updateExistingSubConfig({
       newConfig: {
         import: {
           videos: {
             http: {
-              enabled: true
+              enabled
             },
 
             torrent: {
-              enabled: true
+              enabled
             }
           }
         }
@@ -36,18 +72,45 @@ export class ConfigCommand extends AbstractCommand {
     })
   }
 
+  // ---------------------------------------------------------------------------
+
+  enableChannelSync () {
+    return this.setChannelSyncEnabled(true)
+  }
+
+  disableChannelSync () {
+    return this.setChannelSyncEnabled(false)
+  }
+
+  private setChannelSyncEnabled (enabled: boolean) {
+    return this.updateExistingSubConfig({
+      newConfig: {
+        import: {
+          videoChannelSynchronization: {
+            enabled
+          }
+        }
+      }
+    })
+  }
+
+  // ---------------------------------------------------------------------------
+
   enableLive (options: {
     allowReplay?: boolean
     transcoding?: boolean
+    resolutions?: 'min' | 'max' // Default max
   } = {}) {
+    const { allowReplay, transcoding, resolutions = 'max' } = options
+
     return this.updateExistingSubConfig({
       newConfig: {
         live: {
           enabled: true,
-          allowReplay: options.allowReplay ?? true,
+          allowReplay: allowReplay ?? true,
           transcoding: {
-            enabled: options.transcoding ?? true,
-            resolutions: ConfigCommand.getCustomConfigResolutions(true)
+            enabled: transcoding ?? true,
+            resolutions: ConfigCommand.getCustomConfigResolutions(resolutions === 'max')
           }
         }
       }
@@ -67,7 +130,8 @@ export class ConfigCommand extends AbstractCommand {
     })
   }
 
-  enableTranscoding (webtorrent = true, hls = true) {
+  // TODO: convert args to object
+  enableTranscoding (webtorrent = true, hls = true, with0p = false) {
     return this.updateExistingSubConfig({
       newConfig: {
         transcoding: {
@@ -76,7 +140,7 @@ export class ConfigCommand extends AbstractCommand {
           allowAudioFiles: true,
           allowAdditionalExtensions: true,
 
-          resolutions: ConfigCommand.getCustomConfigResolutions(true),
+          resolutions: ConfigCommand.getCustomConfigResolutions(true, with0p),
 
           webtorrent: {
             enabled: webtorrent
@@ -89,6 +153,7 @@ export class ConfigCommand extends AbstractCommand {
     })
   }
 
+  // TODO: convert args to object
   enableMinimumTranscoding (webtorrent = true, hls = true) {
     return this.updateExistingSubConfig({
       newConfig: {
@@ -111,6 +176,39 @@ export class ConfigCommand extends AbstractCommand {
     })
   }
 
+  enableRemoteTranscoding () {
+    return this.updateExistingSubConfig({
+      newConfig: {
+        transcoding: {
+          remoteRunners: {
+            enabled: true
+          }
+        },
+        live: {
+          transcoding: {
+            remoteRunners: {
+              enabled: true
+            }
+          }
+        }
+      }
+    })
+  }
+
+  enableRemoteStudio () {
+    return this.updateExistingSubConfig({
+      newConfig: {
+        videoStudio: {
+          remoteRunners: {
+            enabled: true
+          }
+        }
+      }
+    })
+  }
+
+  // ---------------------------------------------------------------------------
+
   enableStudio () {
     return this.updateExistingSubConfig({
       newConfig: {
@@ -121,6 +219,8 @@ export class ConfigCommand extends AbstractCommand {
     })
   }
 
+  // ---------------------------------------------------------------------------
+
   getConfig (options: OverrideCommandOptions = {}) {
     const path = '/api/v1/config'
 
@@ -273,6 +373,7 @@ export class ConfigCommand extends AbstractCommand {
       signup: {
         enabled: false,
         limit: 5,
+        requiresApproval: true,
         requiresEmailVerification: false,
         minimumAge: 16
       },
@@ -283,6 +384,11 @@ export class ConfigCommand extends AbstractCommand {
         enabled: true
       },
       user: {
+        history: {
+          videos: {
+            enabled: true
+          }
+        },
         videoQuota: 5242881,
         videoQuotaDaily: 318742
       },
@@ -291,6 +397,9 @@ export class ConfigCommand extends AbstractCommand {
       },
       transcoding: {
         enabled: true,
+        remoteRunners: {
+          enabled: false
+        },
         allowAdditionalExtensions: true,
         allowAudioFiles: true,
         threads: 1,
@@ -307,6 +416,7 @@ export class ConfigCommand extends AbstractCommand {
           '1440p': false,
           '2160p': false
         },
+        alwaysTranscodeOriginalResolution: true,
         webtorrent: {
           enabled: true
         },
@@ -325,6 +435,9 @@ export class ConfigCommand extends AbstractCommand {
         maxUserLives: 50,
         transcoding: {
           enabled: true,
+          remoteRunners: {
+            enabled: false
+          },
           threads: 4,
           profile: 'default',
           resolutions: {
@@ -336,11 +449,15 @@ export class ConfigCommand extends AbstractCommand {
             '1080p': true,
             '1440p': true,
             '2160p': true
-          }
+          },
+          alwaysTranscodeOriginalResolution: true
         }
       },
       videoStudio: {
-        enabled: false
+        enabled: false,
+        remoteRunners: {
+          enabled: false
+        }
       },
       import: {
         videos: {
@@ -351,6 +468,10 @@ export class ConfigCommand extends AbstractCommand {
           torrent: {
             enabled: false
           }
+        },
+        videoChannelSynchronization: {
+          enabled: false,
+          maxPerUser: 10
         }
       },
       trending: {