]>
Commit | Line | Data |
---|---|---|
d175a6f7 | 1 | import { makeDeleteRequest, makeGetRequest, makePutBodyRequest } from '../requests/requests' |
d4681c00 | 2 | import { CustomConfig } from '../../models/server/custom-config.model' |
0e1dc3e7 C |
3 | |
4 | function 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 | ||
14 | function 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 |
24 | function 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 | ||
35 | function 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 |
47 | function 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 | }, | |
7cd4d2ba C |
62 | theme: { |
63 | default: 'default' | |
64 | }, | |
590fb506 C |
65 | services: { |
66 | twitter: { | |
67 | username: '@MySuperUsername', | |
68 | whitelisted: true | |
69 | } | |
70 | }, | |
71 | cache: { | |
72 | previews: { | |
73 | size: 2 | |
74 | }, | |
75 | captions: { | |
76 | size: 3 | |
77 | } | |
78 | }, | |
79 | signup: { | |
80 | enabled: false, | |
d9eaee39 JM |
81 | limit: 5, |
82 | requiresEmailVerification: false | |
590fb506 C |
83 | }, |
84 | admin: { | |
85 | email: 'superadmin1@example.com' | |
86 | }, | |
a4101923 C |
87 | contactForm: { |
88 | enabled: true | |
89 | }, | |
590fb506 | 90 | user: { |
bee0abff FA |
91 | videoQuota: 5242881, |
92 | videoQuotaDaily: 318742 | |
590fb506 C |
93 | }, |
94 | transcoding: { | |
95 | enabled: true, | |
14e2014a | 96 | allowAdditionalExtensions: true, |
536598cf | 97 | allowAudioFiles: true, |
590fb506 C |
98 | threads: 1, |
99 | resolutions: { | |
100 | '240p': false, | |
101 | '360p': true, | |
102 | '480p': true, | |
103 | '720p': false, | |
db714ab4 C |
104 | '1080p': false, |
105 | '2160p': false | |
09209296 C |
106 | }, |
107 | hls: { | |
108 | enabled: false | |
590fb506 C |
109 | } |
110 | }, | |
111 | import: { | |
112 | videos: { | |
113 | http: { | |
114 | enabled: false | |
a84b8fa5 C |
115 | }, |
116 | torrent: { | |
117 | enabled: false | |
590fb506 C |
118 | } |
119 | } | |
7ccddd7b JM |
120 | }, |
121 | autoBlacklist: { | |
122 | videos: { | |
123 | ofUsers: { | |
124 | enabled: false | |
125 | } | |
126 | } | |
5b9c965d C |
127 | }, |
128 | followers: { | |
129 | instance: { | |
14893eb7 C |
130 | enabled: true, |
131 | manualApproval: false | |
5b9c965d | 132 | } |
590fb506 C |
133 | } |
134 | } | |
135 | ||
136 | Object.assign(updateParams, newConfig) | |
137 | ||
138 | return updateCustomConfig(url, token, updateParams) | |
139 | } | |
140 | ||
fd206f0b C |
141 | function deleteCustomConfig (url: string, token: string, statusCodeExpected = 200) { |
142 | const path = '/api/v1/config/custom' | |
143 | ||
144 | return makeDeleteRequest({ | |
145 | url, | |
146 | token, | |
147 | path, | |
148 | statusCodeExpected | |
149 | }) | |
150 | } | |
151 | ||
0e1dc3e7 C |
152 | // --------------------------------------------------------------------------- |
153 | ||
154 | export { | |
fd206f0b C |
155 | getConfig, |
156 | getCustomConfig, | |
157 | updateCustomConfig, | |
36f9424f | 158 | getAbout, |
590fb506 C |
159 | deleteCustomConfig, |
160 | updateCustomSubConfig | |
0e1dc3e7 | 161 | } |