X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=shared%2Fextra-utils%2Fserver%2Fconfig-command.ts;h=51d04fa63891a05a5ed9e0a4b7f7c69bf4467f70;hb=851675c5591dcab1070183f0ed1b1a788de07d2c;hp=6e875fdf6030bfafc3b5eccc7d7f96618b146f4b;hpb=c0e8b12e7fd554ba4d2ceb0c4900804c6a4c63ea;p=github%2FChocobozzz%2FPeerTube.git diff --git a/shared/extra-utils/server/config-command.ts b/shared/extra-utils/server/config-command.ts index 6e875fdf6..51d04fa63 100644 --- a/shared/extra-utils/server/config-command.ts +++ b/shared/extra-utils/server/config-command.ts @@ -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' @@ -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 + }) { + const existing = await this.getCustomConfig(options) + + return this.updateCustomConfig({ ...options, newCustomConfig: merge({}, existing, options.newConfig) }) + } + updateCustomSubConfig (options: OverrideCommandOptions & { newConfig: DeepPartial }) {