]>
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 | ||
58 | moderationInformation: 'my super moderation information', | |
59 | administrator: 'Kuja', | |
60 | maintenanceLifetime: 'forever', | |
61 | businessModel: 'my super business model', | |
62 | ||
63 | languages: [ 'en', 'es' ], | |
64 | categories: [ 1, 2 ], | |
65 | ||
590fb506 | 66 | defaultClientRoute: '/videos/recently-added', |
f8802489 | 67 | isNSFW: true, |
590fb506 C |
68 | defaultNSFWPolicy: 'blur', |
69 | customizations: { | |
70 | javascript: 'alert("coucou")', | |
71 | css: 'body { background-color: red; }' | |
72 | } | |
73 | }, | |
7cd4d2ba C |
74 | theme: { |
75 | default: 'default' | |
76 | }, | |
590fb506 C |
77 | services: { |
78 | twitter: { | |
79 | username: '@MySuperUsername', | |
80 | whitelisted: true | |
81 | } | |
82 | }, | |
83 | cache: { | |
84 | previews: { | |
85 | size: 2 | |
86 | }, | |
87 | captions: { | |
88 | size: 3 | |
89 | } | |
90 | }, | |
91 | signup: { | |
92 | enabled: false, | |
d9eaee39 JM |
93 | limit: 5, |
94 | requiresEmailVerification: false | |
590fb506 C |
95 | }, |
96 | admin: { | |
97 | email: 'superadmin1@example.com' | |
98 | }, | |
a4101923 C |
99 | contactForm: { |
100 | enabled: true | |
101 | }, | |
590fb506 | 102 | user: { |
bee0abff FA |
103 | videoQuota: 5242881, |
104 | videoQuotaDaily: 318742 | |
590fb506 C |
105 | }, |
106 | transcoding: { | |
107 | enabled: true, | |
14e2014a | 108 | allowAdditionalExtensions: true, |
536598cf | 109 | allowAudioFiles: true, |
590fb506 C |
110 | threads: 1, |
111 | resolutions: { | |
112 | '240p': false, | |
113 | '360p': true, | |
114 | '480p': true, | |
115 | '720p': false, | |
db714ab4 C |
116 | '1080p': false, |
117 | '2160p': false | |
09209296 C |
118 | }, |
119 | hls: { | |
120 | enabled: false | |
590fb506 C |
121 | } |
122 | }, | |
123 | import: { | |
124 | videos: { | |
125 | http: { | |
126 | enabled: false | |
a84b8fa5 C |
127 | }, |
128 | torrent: { | |
129 | enabled: false | |
590fb506 C |
130 | } |
131 | } | |
7ccddd7b JM |
132 | }, |
133 | autoBlacklist: { | |
134 | videos: { | |
135 | ofUsers: { | |
136 | enabled: false | |
137 | } | |
138 | } | |
5b9c965d C |
139 | }, |
140 | followers: { | |
141 | instance: { | |
14893eb7 C |
142 | enabled: true, |
143 | manualApproval: false | |
5b9c965d | 144 | } |
8424c402 C |
145 | }, |
146 | followings: { | |
147 | instance: { | |
148 | autoFollowBack: { | |
149 | enabled: false | |
150 | }, | |
151 | autoFollowIndex: { | |
152 | indexUrl: 'https://instances.joinpeertube.org', | |
153 | enabled: false | |
154 | } | |
155 | } | |
590fb506 C |
156 | } |
157 | } | |
158 | ||
8424c402 | 159 | merge(updateParams, newConfig) |
590fb506 C |
160 | |
161 | return updateCustomConfig(url, token, updateParams) | |
162 | } | |
163 | ||
fd206f0b C |
164 | function deleteCustomConfig (url: string, token: string, statusCodeExpected = 200) { |
165 | const path = '/api/v1/config/custom' | |
166 | ||
167 | return makeDeleteRequest({ | |
168 | url, | |
169 | token, | |
170 | path, | |
171 | statusCodeExpected | |
172 | }) | |
173 | } | |
174 | ||
0e1dc3e7 C |
175 | // --------------------------------------------------------------------------- |
176 | ||
177 | export { | |
fd206f0b C |
178 | getConfig, |
179 | getCustomConfig, | |
180 | updateCustomConfig, | |
36f9424f | 181 | getAbout, |
590fb506 C |
182 | deleteCustomConfig, |
183 | updateCustomSubConfig | |
0e1dc3e7 | 184 | } |