1 import { merge } from 'lodash'
2 import { DeepPartial, HttpStatusCode } from '@shared/core-utils'
3 import { About, ServerConfig } from '@shared/models'
4 import { CustomConfig } from '../../models/server/custom-config.model'
5 import { AbstractCommand, OverrideCommandOptions } from '../shared'
7 export class ConfigCommand extends AbstractCommand {
9 static getCustomConfigResolutions (enabled: boolean) {
21 getConfig (options: OverrideCommandOptions = {}) {
22 const path = '/api/v1/config'
24 return this.getRequestBody<ServerConfig>({
29 defaultExpectedStatus: HttpStatusCode.OK_200
33 getAbout (options: OverrideCommandOptions = {}) {
34 const path = '/api/v1/config/about'
36 return this.getRequestBody<About>({
41 defaultExpectedStatus: HttpStatusCode.OK_200
45 getCustomConfig (options: OverrideCommandOptions = {}) {
46 const path = '/api/v1/config/custom'
48 return this.getRequestBody<CustomConfig>({
53 defaultExpectedStatus: HttpStatusCode.OK_200
57 updateCustomConfig (options: OverrideCommandOptions & {
58 newCustomConfig: CustomConfig
60 const path = '/api/v1/config/custom'
62 return this.putBodyRequest({
66 fields: options.newCustomConfig,
68 defaultExpectedStatus: HttpStatusCode.OK_200
72 deleteCustomConfig (options: OverrideCommandOptions = {}) {
73 const path = '/api/v1/config/custom'
75 return this.deleteRequest({
80 defaultExpectedStatus: HttpStatusCode.OK_200
84 updateCustomSubConfig (options: OverrideCommandOptions & {
85 newConfig: DeepPartial<CustomConfig>
87 const newCustomConfig: CustomConfig = {
89 name: 'PeerTube updated',
90 shortDescription: 'my short description',
91 description: 'my super description',
92 terms: 'my super terms',
93 codeOfConduct: 'my super coc',
95 creationReason: 'my super creation reason',
96 moderationInformation: 'my super moderation information',
97 administrator: 'Kuja',
98 maintenanceLifetime: 'forever',
99 businessModel: 'my super business model',
100 hardwareInformation: '2vCore 3GB RAM',
102 languages: [ 'en', 'es' ],
103 categories: [ 1, 2 ],
106 defaultNSFWPolicy: 'blur',
108 defaultClientRoute: '/videos/recently-added',
111 javascript: 'alert("coucou")',
112 css: 'body { background-color: red; }'
120 username: '@MySuperUsername',
138 requiresEmailVerification: false,
142 email: 'superadmin1@example.com'
149 videoQuotaDaily: 318742
153 allowAdditionalExtensions: true,
154 allowAudioFiles: true,
179 maxInstanceLives: -1,
210 enabled: [ 'best', 'hot', 'most-viewed', 'most-liked' ],
225 manualApproval: false
234 indexUrl: 'https://instances.joinpeertube.org/api/v1/instances/hosts',
252 url: 'https://search.joinpeertube.org',
253 disableLocalSearch: true,
254 isDefaultSearch: true
259 merge(newCustomConfig, options.newConfig)
261 return this.updateCustomConfig({ ...options, newCustomConfig })