1 import { makeDeleteRequest, makeGetRequest, makePutBodyRequest } from '../requests/requests'
2 import { CustomConfig } from '../../models/server/custom-config.model'
3 import { DeepPartial } from '@server/typings/utils'
4 import { merge } from 'lodash'
6 function getConfig (url: string) {
7 const path = '/api/v1/config'
9 return makeGetRequest({
12 statusCodeExpected: 200
16 function getAbout (url: string) {
17 const path = '/api/v1/config/about'
19 return makeGetRequest({
22 statusCodeExpected: 200
26 function getCustomConfig (url: string, token: string, statusCodeExpected = 200) {
27 const path = '/api/v1/config/custom'
29 return makeGetRequest({
37 function updateCustomConfig (url: string, token: string, newCustomConfig: CustomConfig, statusCodeExpected = 200) {
38 const path = '/api/v1/config/custom'
40 return makePutBodyRequest({
44 fields: newCustomConfig,
49 function updateCustomSubConfig (url: string, token: string, newConfig: DeepPartial<CustomConfig>) {
50 const updateParams: CustomConfig = {
52 name: 'PeerTube updated',
53 shortDescription: 'my short description',
54 description: 'my super description',
55 terms: 'my super terms',
56 codeOfConduct: 'my super coc',
58 moderationInformation: 'my super moderation information',
59 administrator: 'Kuja',
60 maintenanceLifetime: 'forever',
61 businessModel: 'my super business model',
63 languages: [ 'en', 'es' ],
66 defaultClientRoute: '/videos/recently-added',
68 defaultNSFWPolicy: 'blur',
70 javascript: 'alert("coucou")',
71 css: 'body { background-color: red; }'
79 username: '@MySuperUsername',
94 requiresEmailVerification: false
97 email: 'superadmin1@example.com'
104 videoQuotaDaily: 318742
108 allowAdditionalExtensions: true,
109 allowAudioFiles: true,
143 manualApproval: false
152 indexUrl: 'https://instances.joinpeertube.org',
159 merge(updateParams, newConfig)
161 return updateCustomConfig(url, token, updateParams)
164 function deleteCustomConfig (url: string, token: string, statusCodeExpected = 200) {
165 const path = '/api/v1/config/custom'
167 return makeDeleteRequest({
175 // ---------------------------------------------------------------------------
183 updateCustomSubConfig