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