]>
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 | }, | |
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, |
590fb506 C |
94 | threads: 1, |
95 | resolutions: { | |
96 | '240p': false, | |
97 | '360p': true, | |
98 | '480p': true, | |
99 | '720p': false, | |
100 | '1080p': false | |
09209296 C |
101 | }, |
102 | hls: { | |
103 | enabled: false | |
590fb506 C |
104 | } |
105 | }, | |
106 | import: { | |
107 | videos: { | |
108 | http: { | |
109 | enabled: false | |
a84b8fa5 C |
110 | }, |
111 | torrent: { | |
112 | enabled: false | |
590fb506 C |
113 | } |
114 | } | |
7ccddd7b JM |
115 | }, |
116 | autoBlacklist: { | |
117 | videos: { | |
118 | ofUsers: { | |
119 | enabled: false | |
120 | } | |
121 | } | |
590fb506 C |
122 | } |
123 | } | |
124 | ||
125 | Object.assign(updateParams, newConfig) | |
126 | ||
127 | return updateCustomConfig(url, token, updateParams) | |
128 | } | |
129 | ||
fd206f0b C |
130 | function deleteCustomConfig (url: string, token: string, statusCodeExpected = 200) { |
131 | const path = '/api/v1/config/custom' | |
132 | ||
133 | return makeDeleteRequest({ | |
134 | url, | |
135 | token, | |
136 | path, | |
137 | statusCodeExpected | |
138 | }) | |
139 | } | |
140 | ||
0e1dc3e7 C |
141 | // --------------------------------------------------------------------------- |
142 | ||
143 | export { | |
fd206f0b C |
144 | getConfig, |
145 | getCustomConfig, | |
146 | updateCustomConfig, | |
36f9424f | 147 | getAbout, |
590fb506 C |
148 | deleteCustomConfig, |
149 | updateCustomSubConfig | |
0e1dc3e7 | 150 | } |