]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - shared/extra-utils/server/config.ts
Don't break video scheduled publication
[github/Chocobozzz/PeerTube.git] / shared / extra-utils / server / config.ts
CommitLineData
d175a6f7 1import { makeDeleteRequest, makeGetRequest, makePutBodyRequest } from '../requests/requests'
d4681c00 2import { CustomConfig } from '../../models/server/custom-config.model'
0e1dc3e7
C
3
4function getConfig (url: string) {
5 const path = '/api/v1/config'
6
36f9424f
C
7 return makeGetRequest({
8 url,
9 path,
10 statusCodeExpected: 200
11 })
12}
13
14function getAbout (url: string) {
15 const path = '/api/v1/config/about'
16
17 return makeGetRequest({
18 url,
19 path,
20 statusCodeExpected: 200
21 })
0e1dc3e7
C
22}
23
fd206f0b
C
24function getCustomConfig (url: string, token: string, statusCodeExpected = 200) {
25 const path = '/api/v1/config/custom'
26
27 return makeGetRequest({
28 url,
29 token,
30 path,
31 statusCodeExpected
32 })
33}
34
35function updateCustomConfig (url: string, token: string, newCustomConfig: CustomConfig, statusCodeExpected = 200) {
36 const path = '/api/v1/config/custom'
37
38 return makePutBodyRequest({
39 url,
40 token,
41 path,
42 fields: newCustomConfig,
43 statusCodeExpected
44 })
45}
46
590fb506
C
47function updateCustomSubConfig (url: string, token: string, newConfig: any) {
48 const updateParams: CustomConfig = {
49 instance: {
50 name: 'PeerTube updated',
51 shortDescription: 'my short description',
52 description: 'my super description',
53 terms: 'my super terms',
54 defaultClientRoute: '/videos/recently-added',
f8802489 55 isNSFW: true,
590fb506
C
56 defaultNSFWPolicy: 'blur',
57 customizations: {
58 javascript: 'alert("coucou")',
59 css: 'body { background-color: red; }'
60 }
61 },
62 services: {
63 twitter: {
64 username: '@MySuperUsername',
65 whitelisted: true
66 }
67 },
68 cache: {
69 previews: {
70 size: 2
71 },
72 captions: {
73 size: 3
74 }
75 },
76 signup: {
77 enabled: false,
d9eaee39
JM
78 limit: 5,
79 requiresEmailVerification: false
590fb506
C
80 },
81 admin: {
82 email: 'superadmin1@example.com'
83 },
a4101923
C
84 contactForm: {
85 enabled: true
86 },
590fb506 87 user: {
bee0abff
FA
88 videoQuota: 5242881,
89 videoQuotaDaily: 318742
590fb506
C
90 },
91 transcoding: {
92 enabled: true,
14e2014a 93 allowAdditionalExtensions: true,
536598cf 94 allowAudioFiles: true,
590fb506
C
95 threads: 1,
96 resolutions: {
97 '240p': false,
98 '360p': true,
99 '480p': true,
100 '720p': false,
101 '1080p': false
09209296
C
102 },
103 hls: {
104 enabled: false
590fb506
C
105 }
106 },
107 import: {
108 videos: {
109 http: {
110 enabled: false
a84b8fa5
C
111 },
112 torrent: {
113 enabled: false
590fb506
C
114 }
115 }
7ccddd7b
JM
116 },
117 autoBlacklist: {
118 videos: {
119 ofUsers: {
120 enabled: false
121 }
122 }
5b9c965d
C
123 },
124 followers: {
125 instance: {
14893eb7
C
126 enabled: true,
127 manualApproval: false
5b9c965d 128 }
590fb506
C
129 }
130 }
131
132 Object.assign(updateParams, newConfig)
133
134 return updateCustomConfig(url, token, updateParams)
135}
136
fd206f0b
C
137function deleteCustomConfig (url: string, token: string, statusCodeExpected = 200) {
138 const path = '/api/v1/config/custom'
139
140 return makeDeleteRequest({
141 url,
142 token,
143 path,
144 statusCodeExpected
145 })
146}
147
0e1dc3e7
C
148// ---------------------------------------------------------------------------
149
150export {
fd206f0b
C
151 getConfig,
152 getCustomConfig,
153 updateCustomConfig,
36f9424f 154 getAbout,
590fb506
C
155 deleteCustomConfig,
156 updateCustomSubConfig
0e1dc3e7 157}