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>({
52 defaultExpectedStatus: HttpStatusCode.OK_200
56 updateCustomConfig (options: OverrideCommandOptions & {
57 newCustomConfig: CustomConfig
59 const path = '/api/v1/config/custom'
61 return this.putBodyRequest({
65 fields: options.newCustomConfig,
66 defaultExpectedStatus: HttpStatusCode.OK_200
70 deleteCustomConfig (options: OverrideCommandOptions = {}) {
71 const path = '/api/v1/config/custom'
73 return this.deleteRequest({
77 defaultExpectedStatus: HttpStatusCode.OK_200
81 updateCustomSubConfig (options: OverrideCommandOptions & {
82 newConfig: DeepPartial<CustomConfig>
84 const newCustomConfig: CustomConfig = {
86 name: 'PeerTube updated',
87 shortDescription: 'my short description',
88 description: 'my super description',
89 terms: 'my super terms',
90 codeOfConduct: 'my super coc',
92 creationReason: 'my super creation reason',
93 moderationInformation: 'my super moderation information',
94 administrator: 'Kuja',
95 maintenanceLifetime: 'forever',
96 businessModel: 'my super business model',
97 hardwareInformation: '2vCore 3GB RAM',
99 languages: [ 'en', 'es' ],
100 categories: [ 1, 2 ],
103 defaultNSFWPolicy: 'blur',
105 defaultClientRoute: '/videos/recently-added',
108 javascript: 'alert("coucou")',
109 css: 'body { background-color: red; }'
117 username: '@MySuperUsername',
135 requiresEmailVerification: false,
139 email: 'superadmin1@example.com'
146 videoQuotaDaily: 318742
150 allowAdditionalExtensions: true,
151 allowAudioFiles: true,
176 maxInstanceLives: -1,
207 enabled: [ 'best', 'hot', 'most-viewed', 'most-liked' ],
222 manualApproval: false
231 indexUrl: 'https://instances.joinpeertube.org/api/v1/instances/hosts',
249 url: 'https://search.joinpeertube.org',
250 disableLocalSearch: true,
251 isDefaultSearch: true
256 merge(newCustomConfig, options.newConfig)
258 return this.updateCustomConfig({ ...options, newCustomConfig })