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