1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
import { makeDeleteRequest, makeGetRequest, makePutBodyRequest } from '../requests/requests'
import { CustomConfig } from '../../models/server/custom-config.model'
import { DeepPartial } from '@server/typings/utils'
import { merge } from 'lodash'
function getConfig (url: string) {
const path = '/api/v1/config'
return makeGetRequest({
url,
path,
statusCodeExpected: 200
})
}
function getAbout (url: string) {
const path = '/api/v1/config/about'
return makeGetRequest({
url,
path,
statusCodeExpected: 200
})
}
function getCustomConfig (url: string, token: string, statusCodeExpected = 200) {
const path = '/api/v1/config/custom'
return makeGetRequest({
url,
token,
path,
statusCodeExpected
})
}
function updateCustomConfig (url: string, token: string, newCustomConfig: CustomConfig, statusCodeExpected = 200) {
const path = '/api/v1/config/custom'
return makePutBodyRequest({
url,
token,
path,
fields: newCustomConfig,
statusCodeExpected
})
}
function updateCustomSubConfig (url: string, token: string, newConfig: DeepPartial<CustomConfig>) {
const updateParams: CustomConfig = {
instance: {
name: 'PeerTube updated',
shortDescription: 'my short description',
description: 'my super description',
terms: 'my super terms',
codeOfConduct: 'my super coc',
creationReason: 'my super creation reason',
moderationInformation: 'my super moderation information',
administrator: 'Kuja',
maintenanceLifetime: 'forever',
businessModel: 'my super business model',
languages: [ 'en', 'es' ],
categories: [ 1, 2 ],
defaultClientRoute: '/videos/recently-added',
isNSFW: true,
defaultNSFWPolicy: 'blur',
customizations: {
javascript: 'alert("coucou")',
css: 'body { background-color: red; }'
}
},
theme: {
default: 'default'
},
services: {
twitter: {
username: '@MySuperUsername',
whitelisted: true
}
},
cache: {
previews: {
size: 2
},
captions: {
size: 3
}
},
signup: {
enabled: false,
limit: 5,
requiresEmailVerification: false
},
admin: {
email: 'superadmin1@example.com'
},
contactForm: {
enabled: true
},
user: {
videoQuota: 5242881,
videoQuotaDaily: 318742
},
transcoding: {
enabled: true,
allowAdditionalExtensions: true,
allowAudioFiles: true,
threads: 1,
resolutions: {
'240p': false,
'360p': true,
'480p': true,
'720p': false,
'1080p': false,
'2160p': false
},
hls: {
enabled: false
}
},
import: {
videos: {
http: {
enabled: false
},
torrent: {
enabled: false
}
}
},
autoBlacklist: {
videos: {
ofUsers: {
enabled: false
}
}
},
followers: {
instance: {
enabled: true,
manualApproval: false
}
},
followings: {
instance: {
autoFollowBack: {
enabled: false
},
autoFollowIndex: {
indexUrl: 'https://instances.joinpeertube.org',
enabled: false
}
}
}
}
merge(updateParams, newConfig)
return updateCustomConfig(url, token, updateParams)
}
function deleteCustomConfig (url: string, token: string, statusCodeExpected = 200) {
const path = '/api/v1/config/custom'
return makeDeleteRequest({
url,
token,
path,
statusCodeExpected
})
}
// ---------------------------------------------------------------------------
export {
getConfig,
getCustomConfig,
updateCustomConfig,
getAbout,
deleteCustomConfig,
updateCustomSubConfig
}
|