]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - shared/utils/server/config.ts
Add ability to forbid followers
[github/Chocobozzz/PeerTube.git] / shared / utils / server / config.ts
CommitLineData
d175a6f7 1import { makeDeleteRequest, makeGetRequest, makePutBodyRequest } from '../requests/requests'
d4681c00 2import { CustomConfig } from '../../models/server/custom-config.model'
0e1dc3e7
C
3
4function 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
14function 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
24function 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
35function 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
47function 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 }
5b9c965d
C
122 },
123 followers: {
124 instance: {
125 enabled: true
126 }
590fb506
C
127 }
128 }
129
130 Object.assign(updateParams, newConfig)
131
132 return updateCustomConfig(url, token, updateParams)
133}
134
fd206f0b
C
135function deleteCustomConfig (url: string, token: string, statusCodeExpected = 200) {
136 const path = '/api/v1/config/custom'
137
138 return makeDeleteRequest({
139 url,
140 token,
141 path,
142 statusCodeExpected
143 })
144}
145
0e1dc3e7
C
146// ---------------------------------------------------------------------------
147
148export {
fd206f0b
C
149 getConfig,
150 getCustomConfig,
151 updateCustomConfig,
36f9424f 152 getAbout,
590fb506
C
153 deleteCustomConfig,
154 updateCustomSubConfig
0e1dc3e7 155}