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 creationReason: 'my super creation reason',
59 moderationInformation: 'my super moderation information',
60 administrator: 'Kuja',
61 maintenanceLifetime: 'forever',
62 businessModel: 'my super business model',
63 hardwareInformation: '2vCore 3GB RAM',
65 languages: [ 'en', 'es' ],
68 defaultClientRoute: '/videos/recently-added',
70 defaultNSFWPolicy: 'blur',
72 javascript: 'alert("coucou")',
73 css: 'body { background-color: red; }'
81 username: '@MySuperUsername',
96 requiresEmailVerification: false
99 email: 'superadmin1@example.com'
106 videoQuotaDaily: 318742
110 allowAdditionalExtensions: true,
111 allowAudioFiles: true,
149 manualApproval: false
158 indexUrl: 'https://instances.joinpeertube.org',
165 merge(updateParams, newConfig)
167 return updateCustomConfig(url, token, updateParams)
170 function deleteCustomConfig (url: string, token: string, statusCodeExpected = 200) {
171 const path = '/api/v1/config/custom'
173 return makeDeleteRequest({
181 // ---------------------------------------------------------------------------
189 updateCustomSubConfig