mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 02:39:33 +02:00
Remove difficult to maintain config update method
This commit is contained in:
parent
5ef0430dfb
commit
817f754c22
41 changed files with 148 additions and 451 deletions
|
@ -1,6 +1,6 @@
|
|||
import merge from 'lodash-es/merge.js'
|
||||
import { About, ActorImageType, ActorImageType_Type, CustomConfig, HttpStatusCode, ServerConfig } from '@peertube/peertube-models'
|
||||
import { DeepPartial } from '@peertube/peertube-typescript-utils'
|
||||
import merge from 'lodash-es/merge.js'
|
||||
import { AbstractCommand, OverrideCommandOptions } from '../shared/abstract-command.js'
|
||||
|
||||
export class ConfigCommand extends AbstractCommand {
|
||||
|
@ -43,7 +43,7 @@ export class ConfigCommand extends AbstractCommand {
|
|||
// ---------------------------------------------------------------------------
|
||||
|
||||
enableSignup (requiresApproval: boolean, limit = -1) {
|
||||
return this.updateExistingSubConfig({
|
||||
return this.updateExistingConfig({
|
||||
newConfig: {
|
||||
signup: {
|
||||
enabled: true,
|
||||
|
@ -65,7 +65,7 @@ export class ConfigCommand extends AbstractCommand {
|
|||
}
|
||||
|
||||
private setVideoImportsEnabled (enabled: boolean) {
|
||||
return this.updateExistingSubConfig({
|
||||
return this.updateExistingConfig({
|
||||
newConfig: {
|
||||
import: {
|
||||
videos: {
|
||||
|
@ -93,7 +93,7 @@ export class ConfigCommand extends AbstractCommand {
|
|||
}
|
||||
|
||||
private setFileUpdateEnabled (enabled: boolean) {
|
||||
return this.updateExistingSubConfig({
|
||||
return this.updateExistingConfig({
|
||||
newConfig: {
|
||||
videoFile: {
|
||||
update: {
|
||||
|
@ -107,7 +107,7 @@ export class ConfigCommand extends AbstractCommand {
|
|||
// ---------------------------------------------------------------------------
|
||||
|
||||
keepSourceFile () {
|
||||
return this.updateExistingSubConfig({
|
||||
return this.updateExistingConfig({
|
||||
newConfig: {
|
||||
transcoding: {
|
||||
originalFile: {
|
||||
|
@ -128,7 +128,7 @@ export class ConfigCommand extends AbstractCommand {
|
|||
}
|
||||
|
||||
private setChannelSyncEnabled (enabled: boolean) {
|
||||
return this.updateExistingSubConfig({
|
||||
return this.updateExistingConfig({
|
||||
newConfig: {
|
||||
import: {
|
||||
videoChannelSynchronization: {
|
||||
|
@ -150,7 +150,7 @@ export class ConfigCommand extends AbstractCommand {
|
|||
}
|
||||
|
||||
private setAutoblacklistEnabled (enabled: boolean) {
|
||||
return this.updateExistingSubConfig({
|
||||
return this.updateExistingConfig({
|
||||
newConfig: {
|
||||
autoBlacklist: {
|
||||
videos: {
|
||||
|
@ -174,7 +174,7 @@ export class ConfigCommand extends AbstractCommand {
|
|||
}
|
||||
|
||||
private setUserImportEnabled (enabled: boolean) {
|
||||
return this.updateExistingSubConfig({
|
||||
return this.updateExistingConfig({
|
||||
newConfig: {
|
||||
import: {
|
||||
users: {
|
||||
|
@ -196,7 +196,7 @@ export class ConfigCommand extends AbstractCommand {
|
|||
}
|
||||
|
||||
private setUserExportEnabled (enabled: boolean) {
|
||||
return this.updateExistingSubConfig({
|
||||
return this.updateExistingConfig({
|
||||
newConfig: {
|
||||
export: {
|
||||
users: {
|
||||
|
@ -216,7 +216,7 @@ export class ConfigCommand extends AbstractCommand {
|
|||
} = {}) {
|
||||
const { allowReplay, transcoding, resolutions = 'max' } = options
|
||||
|
||||
return this.updateExistingSubConfig({
|
||||
return this.updateExistingConfig({
|
||||
newConfig: {
|
||||
live: {
|
||||
enabled: true,
|
||||
|
@ -231,7 +231,7 @@ export class ConfigCommand extends AbstractCommand {
|
|||
}
|
||||
|
||||
disableTranscoding () {
|
||||
return this.updateExistingSubConfig({
|
||||
return this.updateExistingConfig({
|
||||
newConfig: {
|
||||
transcoding: {
|
||||
enabled: false
|
||||
|
@ -251,7 +251,7 @@ export class ConfigCommand extends AbstractCommand {
|
|||
} = {}) {
|
||||
const { webVideo = true, hls = true, with0p = false, keepOriginal = false } = options
|
||||
|
||||
return this.updateExistingSubConfig({
|
||||
return this.updateExistingConfig({
|
||||
newConfig: {
|
||||
transcoding: {
|
||||
enabled: true,
|
||||
|
@ -282,7 +282,7 @@ export class ConfigCommand extends AbstractCommand {
|
|||
} = {}) {
|
||||
const { webVideo = true, hls = true, keepOriginal = false } = options
|
||||
|
||||
return this.updateExistingSubConfig({
|
||||
return this.updateExistingConfig({
|
||||
newConfig: {
|
||||
transcoding: {
|
||||
enabled: true,
|
||||
|
@ -311,7 +311,7 @@ export class ConfigCommand extends AbstractCommand {
|
|||
}
|
||||
|
||||
enableRemoteTranscoding () {
|
||||
return this.updateExistingSubConfig({
|
||||
return this.updateExistingConfig({
|
||||
newConfig: {
|
||||
transcoding: {
|
||||
remoteRunners: {
|
||||
|
@ -330,7 +330,7 @@ export class ConfigCommand extends AbstractCommand {
|
|||
}
|
||||
|
||||
enableRemoteStudio () {
|
||||
return this.updateExistingSubConfig({
|
||||
return this.updateExistingConfig({
|
||||
newConfig: {
|
||||
videoStudio: {
|
||||
remoteRunners: {
|
||||
|
@ -344,7 +344,7 @@ export class ConfigCommand extends AbstractCommand {
|
|||
// ---------------------------------------------------------------------------
|
||||
|
||||
enableStudio () {
|
||||
return this.updateExistingSubConfig({
|
||||
return this.updateExistingConfig({
|
||||
newConfig: {
|
||||
videoStudio: {
|
||||
enabled: true
|
||||
|
@ -480,259 +480,11 @@ export class ConfigCommand extends AbstractCommand {
|
|||
})
|
||||
}
|
||||
|
||||
async updateExistingSubConfig (options: OverrideCommandOptions & {
|
||||
async updateExistingConfig (options: OverrideCommandOptions & {
|
||||
newConfig: DeepPartial<CustomConfig>
|
||||
}) {
|
||||
const existing = await this.getCustomConfig({ ...options, expectedStatus: HttpStatusCode.OK_200 })
|
||||
|
||||
return this.updateCustomConfig({ ...options, newCustomConfig: merge({}, existing, options.newConfig) })
|
||||
}
|
||||
|
||||
updateCustomSubConfig (options: OverrideCommandOptions & {
|
||||
newConfig: DeepPartial<CustomConfig>
|
||||
}) {
|
||||
const newCustomConfig: CustomConfig = {
|
||||
instance: {
|
||||
name: 'PeerTube updated',
|
||||
shortDescription: 'my short description',
|
||||
description: 'my super description',
|
||||
terms: 'my super terms',
|
||||
codeOfConduct: 'my super coc',
|
||||
|
||||
creationReason: 'my super creation reason',
|
||||
moderationInformation: 'my super moderation information',
|
||||
administrator: 'Kuja',
|
||||
maintenanceLifetime: 'forever',
|
||||
businessModel: 'my super business model',
|
||||
hardwareInformation: '2vCore 3GB RAM',
|
||||
|
||||
languages: [ 'en', 'es' ],
|
||||
categories: [ 1, 2 ],
|
||||
|
||||
isNSFW: true,
|
||||
defaultNSFWPolicy: 'blur',
|
||||
|
||||
defaultClientRoute: '/videos/recently-added',
|
||||
|
||||
customizations: {
|
||||
javascript: 'alert("coucou")',
|
||||
css: 'body { background-color: red; }'
|
||||
}
|
||||
},
|
||||
theme: {
|
||||
default: 'default'
|
||||
},
|
||||
services: {
|
||||
twitter: {
|
||||
username: '@MySuperUsername'
|
||||
}
|
||||
},
|
||||
client: {
|
||||
videos: {
|
||||
miniature: {
|
||||
preferAuthorDisplayName: false
|
||||
}
|
||||
},
|
||||
menu: {
|
||||
login: {
|
||||
redirectOnSingleExternalAuth: false
|
||||
}
|
||||
}
|
||||
},
|
||||
cache: {
|
||||
previews: {
|
||||
size: 2
|
||||
},
|
||||
captions: {
|
||||
size: 3
|
||||
},
|
||||
torrents: {
|
||||
size: 4
|
||||
},
|
||||
storyboards: {
|
||||
size: 5
|
||||
}
|
||||
},
|
||||
signup: {
|
||||
enabled: false,
|
||||
limit: 5,
|
||||
requiresApproval: true,
|
||||
requiresEmailVerification: false,
|
||||
minimumAge: 16
|
||||
},
|
||||
admin: {
|
||||
email: 'superadmin1@example.com'
|
||||
},
|
||||
contactForm: {
|
||||
enabled: true
|
||||
},
|
||||
user: {
|
||||
history: {
|
||||
videos: {
|
||||
enabled: true
|
||||
}
|
||||
},
|
||||
videoQuota: 5242881,
|
||||
videoQuotaDaily: 318742,
|
||||
defaultChannelName: 'Main $1 channel'
|
||||
},
|
||||
videoChannels: {
|
||||
maxPerUser: 20
|
||||
},
|
||||
transcoding: {
|
||||
enabled: true,
|
||||
originalFile: {
|
||||
keep: false
|
||||
},
|
||||
remoteRunners: {
|
||||
enabled: false
|
||||
},
|
||||
allowAdditionalExtensions: true,
|
||||
allowAudioFiles: true,
|
||||
threads: 1,
|
||||
concurrency: 3,
|
||||
profile: 'default',
|
||||
resolutions: {
|
||||
'0p': false,
|
||||
'144p': false,
|
||||
'240p': false,
|
||||
'360p': true,
|
||||
'480p': true,
|
||||
'720p': false,
|
||||
'1080p': false,
|
||||
'1440p': false,
|
||||
'2160p': false
|
||||
},
|
||||
alwaysTranscodeOriginalResolution: true,
|
||||
webVideos: {
|
||||
enabled: true
|
||||
},
|
||||
hls: {
|
||||
enabled: false
|
||||
}
|
||||
},
|
||||
live: {
|
||||
enabled: true,
|
||||
allowReplay: false,
|
||||
latencySetting: {
|
||||
enabled: false
|
||||
},
|
||||
maxDuration: -1,
|
||||
maxInstanceLives: -1,
|
||||
maxUserLives: 50,
|
||||
transcoding: {
|
||||
enabled: true,
|
||||
remoteRunners: {
|
||||
enabled: false
|
||||
},
|
||||
threads: 4,
|
||||
profile: 'default',
|
||||
resolutions: {
|
||||
'144p': true,
|
||||
'240p': true,
|
||||
'360p': true,
|
||||
'480p': true,
|
||||
'720p': true,
|
||||
'1080p': true,
|
||||
'1440p': true,
|
||||
'2160p': true
|
||||
},
|
||||
alwaysTranscodeOriginalResolution: true
|
||||
}
|
||||
},
|
||||
videoStudio: {
|
||||
enabled: false,
|
||||
remoteRunners: {
|
||||
enabled: false
|
||||
}
|
||||
},
|
||||
videoFile: {
|
||||
update: {
|
||||
enabled: false
|
||||
}
|
||||
},
|
||||
import: {
|
||||
videos: {
|
||||
concurrency: 3,
|
||||
http: {
|
||||
enabled: false
|
||||
},
|
||||
torrent: {
|
||||
enabled: false
|
||||
}
|
||||
},
|
||||
videoChannelSynchronization: {
|
||||
enabled: false,
|
||||
maxPerUser: 10
|
||||
},
|
||||
users: {
|
||||
enabled: true
|
||||
}
|
||||
},
|
||||
export: {
|
||||
users: {
|
||||
enabled: true,
|
||||
maxUserVideoQuota: 5242881,
|
||||
exportExpiration: 1000 * 3600
|
||||
}
|
||||
},
|
||||
trending: {
|
||||
videos: {
|
||||
algorithms: {
|
||||
enabled: [ 'hot', 'most-viewed', 'most-liked' ],
|
||||
default: 'hot'
|
||||
}
|
||||
}
|
||||
},
|
||||
autoBlacklist: {
|
||||
videos: {
|
||||
ofUsers: {
|
||||
enabled: false
|
||||
}
|
||||
}
|
||||
},
|
||||
followers: {
|
||||
instance: {
|
||||
enabled: true,
|
||||
manualApproval: false
|
||||
}
|
||||
},
|
||||
followings: {
|
||||
instance: {
|
||||
autoFollowBack: {
|
||||
enabled: false
|
||||
},
|
||||
autoFollowIndex: {
|
||||
indexUrl: 'https://instances.joinpeertube.org/api/v1/instances/hosts',
|
||||
enabled: false
|
||||
}
|
||||
}
|
||||
},
|
||||
broadcastMessage: {
|
||||
enabled: true,
|
||||
level: 'warning',
|
||||
message: 'hello',
|
||||
dismissable: true
|
||||
},
|
||||
search: {
|
||||
remoteUri: {
|
||||
users: true,
|
||||
anonymous: true
|
||||
},
|
||||
searchIndex: {
|
||||
enabled: true,
|
||||
url: 'https://search.joinpeertube.org',
|
||||
disableLocalSearch: true,
|
||||
isDefaultSearch: true
|
||||
}
|
||||
},
|
||||
storyboards: {
|
||||
enabled: true
|
||||
}
|
||||
}
|
||||
|
||||
merge(newCustomConfig, options.newConfig)
|
||||
|
||||
return this.updateCustomConfig({ ...options, newCustomConfig })
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue