1 import { makeDeleteRequest, makeGetRequest, makePutBodyRequest } from '../requests/requests'
2 import { CustomConfig } from '../../models/server/custom-config.model'
3 import { DeepPartial, HttpStatusCode } from '@shared/core-utils'
4 import { merge } from 'lodash'
6 function getConfig (url: string) {
7 const path = '/api/v1/config'
9 return makeGetRequest({
12 statusCodeExpected: HttpStatusCode.OK_200
16 function getAbout (url: string) {
17 const path = '/api/v1/config/about'
19 return makeGetRequest({
22 statusCodeExpected: HttpStatusCode.OK_200
26 function getCustomConfig (url: string, token: string, statusCodeExpected = HttpStatusCode.OK_200) {
27 const path = '/api/v1/config/custom'
29 return makeGetRequest({
37 function updateCustomConfig (url: string, token: string, newCustomConfig: CustomConfig, statusCodeExpected = HttpStatusCode.OK_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' ],
69 defaultNSFWPolicy: 'blur',
71 defaultClientRoute: '/videos/recently-added',
74 javascript: 'alert("coucou")',
75 css: 'body { background-color: red; }'
83 username: '@MySuperUsername',
101 requiresEmailVerification: false
104 email: 'superadmin1@example.com'
111 videoQuotaDaily: 318742
115 allowAdditionalExtensions: true,
116 allowAudioFiles: true,
141 maxInstanceLives: -1,
172 enabled: [ 'best', 'hot', 'most-viewed', 'most-liked' ],
187 manualApproval: false
196 indexUrl: 'https://instances.joinpeertube.org/api/v1/instances/hosts',
214 url: 'https://search.joinpeertube.org',
215 disableLocalSearch: true,
216 isDefaultSearch: true
221 merge(updateParams, newConfig)
223 return updateCustomConfig(url, token, updateParams)
226 function deleteCustomConfig (url: string, token: string, statusCodeExpected = HttpStatusCode.OK_200) {
227 const path = '/api/v1/config/custom'
229 return makeDeleteRequest({
237 // ---------------------------------------------------------------------------
245 updateCustomSubConfig