diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/controllers/api/config.ts | 4 | ||||
-rw-r--r-- | server/initializers/constants.ts | 1 | ||||
-rw-r--r-- | server/middlewares/validators/config.ts | 6 | ||||
-rw-r--r-- | server/tests/api/check-params/config.ts | 1 | ||||
-rw-r--r-- | server/tests/api/server/config.ts | 5 |
5 files changed, 17 insertions, 0 deletions
diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts index 427125810..a25d7a157 100644 --- a/server/controllers/api/config.ts +++ b/server/controllers/api/config.ts | |||
@@ -44,6 +44,7 @@ async function getConfig (req: express.Request, res: express.Response, next: exp | |||
44 | const json: ServerConfig = { | 44 | const json: ServerConfig = { |
45 | instance: { | 45 | instance: { |
46 | name: CONFIG.INSTANCE.NAME, | 46 | name: CONFIG.INSTANCE.NAME, |
47 | defaultClientRoute: CONFIG.INSTANCE.DEFAULT_CLIENT_ROUTE, | ||
47 | customizations: { | 48 | customizations: { |
48 | javascript: CONFIG.INSTANCE.CUSTOMIZATIONS.JAVASCRIPT, | 49 | javascript: CONFIG.INSTANCE.CUSTOMIZATIONS.JAVASCRIPT, |
49 | css: CONFIG.INSTANCE.CUSTOMIZATIONS.CSS | 50 | css: CONFIG.INSTANCE.CUSTOMIZATIONS.CSS |
@@ -114,7 +115,9 @@ async function updateCustomConfig (req: express.Request, res: express.Response, | |||
114 | // Need to change the videoQuota key a little bit | 115 | // Need to change the videoQuota key a little bit |
115 | const toUpdateJSON = omit(toUpdate, 'videoQuota') | 116 | const toUpdateJSON = omit(toUpdate, 'videoQuota') |
116 | toUpdateJSON.user['video_quota'] = toUpdate.user.videoQuota | 117 | toUpdateJSON.user['video_quota'] = toUpdate.user.videoQuota |
118 | toUpdateJSON.instance['default_client_route'] = toUpdate.instance.defaultClientRoute | ||
117 | delete toUpdate.user.videoQuota | 119 | delete toUpdate.user.videoQuota |
120 | delete toUpdate.instance.defaultClientRoute | ||
118 | 121 | ||
119 | await writeFilePromise(CONFIG.CUSTOM_FILE, JSON.stringify(toUpdateJSON, undefined, 2)) | 122 | await writeFilePromise(CONFIG.CUSTOM_FILE, JSON.stringify(toUpdateJSON, undefined, 2)) |
120 | 123 | ||
@@ -138,6 +141,7 @@ function customConfig (): CustomConfig { | |||
138 | name: CONFIG.INSTANCE.NAME, | 141 | name: CONFIG.INSTANCE.NAME, |
139 | description: CONFIG.INSTANCE.DESCRIPTION, | 142 | description: CONFIG.INSTANCE.DESCRIPTION, |
140 | terms: CONFIG.INSTANCE.TERMS, | 143 | terms: CONFIG.INSTANCE.TERMS, |
144 | defaultClientRoute: CONFIG.INSTANCE.DEFAULT_CLIENT_ROUTE, | ||
141 | customizations: { | 145 | customizations: { |
142 | css: CONFIG.INSTANCE.CUSTOMIZATIONS.CSS, | 146 | css: CONFIG.INSTANCE.CUSTOMIZATIONS.CSS, |
143 | javascript: CONFIG.INSTANCE.CUSTOMIZATIONS.JAVASCRIPT | 147 | javascript: CONFIG.INSTANCE.CUSTOMIZATIONS.JAVASCRIPT |
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 318df48bf..5946bcd11 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts | |||
@@ -159,6 +159,7 @@ const CONFIG = { | |||
159 | get NAME () { return config.get<string>('instance.name') }, | 159 | get NAME () { return config.get<string>('instance.name') }, |
160 | get DESCRIPTION () { return config.get<string>('instance.description') }, | 160 | get DESCRIPTION () { return config.get<string>('instance.description') }, |
161 | get TERMS () { return config.get<string>('instance.terms') }, | 161 | get TERMS () { return config.get<string>('instance.terms') }, |
162 | get DEFAULT_CLIENT_ROUTE () { return config.get<string>('instance.default_client_route') }, | ||
162 | CUSTOMIZATIONS: { | 163 | CUSTOMIZATIONS: { |
163 | get JAVASCRIPT () { return config.get<string>('instance.customizations.javascript') }, | 164 | get JAVASCRIPT () { return config.get<string>('instance.customizations.javascript') }, |
164 | get CSS () { return config.get<string>('instance.customizations.css') } | 165 | get CSS () { return config.get<string>('instance.customizations.css') } |
diff --git a/server/middlewares/validators/config.ts b/server/middlewares/validators/config.ts index 800aaf107..ee6f6efa4 100644 --- a/server/middlewares/validators/config.ts +++ b/server/middlewares/validators/config.ts | |||
@@ -5,6 +5,12 @@ import { logger } from '../../helpers/logger' | |||
5 | import { areValidationErrors } from './utils' | 5 | import { areValidationErrors } from './utils' |
6 | 6 | ||
7 | const customConfigUpdateValidator = [ | 7 | const customConfigUpdateValidator = [ |
8 | body('instance.name').exists().withMessage('Should have a valid instance name'), | ||
9 | body('instance.description').exists().withMessage('Should have a valid instance description'), | ||
10 | body('instance.terms').exists().withMessage('Should have a valid instance terms'), | ||
11 | body('instance.defaultClientRoute').exists().withMessage('Should have a valid instance default client route'), | ||
12 | body('instance.customizations.css').exists().withMessage('Should have a valid instance CSS customization'), | ||
13 | body('instance.customizations.javascript').exists().withMessage('Should have a valid instance JavaScript customization'), | ||
8 | body('cache.previews.size').isInt().withMessage('Should have a valid previews size'), | 14 | body('cache.previews.size').isInt().withMessage('Should have a valid previews size'), |
9 | body('signup.enabled').isBoolean().withMessage('Should have a valid signup enabled boolean'), | 15 | body('signup.enabled').isBoolean().withMessage('Should have a valid signup enabled boolean'), |
10 | body('signup.limit').isInt().withMessage('Should have a valid signup limit'), | 16 | body('signup.limit').isInt().withMessage('Should have a valid signup limit'), |
diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.ts index a66e51a6a..ca8239270 100644 --- a/server/tests/api/check-params/config.ts +++ b/server/tests/api/check-params/config.ts | |||
@@ -18,6 +18,7 @@ describe('Test config API validators', function () { | |||
18 | name: 'PeerTube updated', | 18 | name: 'PeerTube updated', |
19 | description: 'my super description', | 19 | description: 'my super description', |
20 | terms: 'my super terms', | 20 | terms: 'my super terms', |
21 | defaultClientRoute: '/videos/recently-added', | ||
21 | customizations: { | 22 | customizations: { |
22 | javascript: 'alert("coucou")', | 23 | javascript: 'alert("coucou")', |
23 | css: 'body { background-color: red; }' | 24 | css: 'body { background-color: red; }' |
diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.ts index 3d90580d8..271a57275 100644 --- a/server/tests/api/server/config.ts +++ b/server/tests/api/server/config.ts | |||
@@ -54,6 +54,7 @@ describe('Test config', function () { | |||
54 | expect(data.instance.name).to.equal('PeerTube') | 54 | expect(data.instance.name).to.equal('PeerTube') |
55 | expect(data.instance.description).to.equal('Welcome to this PeerTube instance!') | 55 | expect(data.instance.description).to.equal('Welcome to this PeerTube instance!') |
56 | expect(data.instance.terms).to.equal('No terms for now.') | 56 | expect(data.instance.terms).to.equal('No terms for now.') |
57 | expect(data.instance.defaultClientRoute).to.equal('/videos/trending') | ||
57 | expect(data.instance.customizations.css).to.be.empty | 58 | expect(data.instance.customizations.css).to.be.empty |
58 | expect(data.instance.customizations.javascript).to.be.empty | 59 | expect(data.instance.customizations.javascript).to.be.empty |
59 | expect(data.cache.previews.size).to.equal(1) | 60 | expect(data.cache.previews.size).to.equal(1) |
@@ -76,6 +77,7 @@ describe('Test config', function () { | |||
76 | name: 'PeerTube updated', | 77 | name: 'PeerTube updated', |
77 | description: 'my super description', | 78 | description: 'my super description', |
78 | terms: 'my super terms', | 79 | terms: 'my super terms', |
80 | defaultClientRoute: '/videos/recently-added', | ||
79 | customizations: { | 81 | customizations: { |
80 | javascript: 'alert("coucou")', | 82 | javascript: 'alert("coucou")', |
81 | css: 'body { background-color: red; }' | 83 | css: 'body { background-color: red; }' |
@@ -116,6 +118,7 @@ describe('Test config', function () { | |||
116 | expect(data.instance.name).to.equal('PeerTube updated') | 118 | expect(data.instance.name).to.equal('PeerTube updated') |
117 | expect(data.instance.description).to.equal('my super description') | 119 | expect(data.instance.description).to.equal('my super description') |
118 | expect(data.instance.terms).to.equal('my super terms') | 120 | expect(data.instance.terms).to.equal('my super terms') |
121 | expect(data.instance.defaultClientRoute).to.equal('/videos/recently-added') | ||
119 | expect(data.instance.customizations.javascript).to.equal('alert("coucou")') | 122 | expect(data.instance.customizations.javascript).to.equal('alert("coucou")') |
120 | expect(data.instance.customizations.css).to.equal('body { background-color: red; }') | 123 | expect(data.instance.customizations.css).to.equal('body { background-color: red; }') |
121 | expect(data.cache.previews.size).to.equal(2) | 124 | expect(data.cache.previews.size).to.equal(2) |
@@ -145,6 +148,7 @@ describe('Test config', function () { | |||
145 | expect(data.instance.name).to.equal('PeerTube updated') | 148 | expect(data.instance.name).to.equal('PeerTube updated') |
146 | expect(data.instance.description).to.equal('my super description') | 149 | expect(data.instance.description).to.equal('my super description') |
147 | expect(data.instance.terms).to.equal('my super terms') | 150 | expect(data.instance.terms).to.equal('my super terms') |
151 | expect(data.instance.defaultClientRoute).to.equal('/videos/recently-added') | ||
148 | expect(data.instance.customizations.javascript).to.equal('alert("coucou")') | 152 | expect(data.instance.customizations.javascript).to.equal('alert("coucou")') |
149 | expect(data.instance.customizations.css).to.equal('body { background-color: red; }') | 153 | expect(data.instance.customizations.css).to.equal('body { background-color: red; }') |
150 | expect(data.cache.previews.size).to.equal(2) | 154 | expect(data.cache.previews.size).to.equal(2) |
@@ -181,6 +185,7 @@ describe('Test config', function () { | |||
181 | expect(data.instance.name).to.equal('PeerTube') | 185 | expect(data.instance.name).to.equal('PeerTube') |
182 | expect(data.instance.description).to.equal('Welcome to this PeerTube instance!') | 186 | expect(data.instance.description).to.equal('Welcome to this PeerTube instance!') |
183 | expect(data.instance.terms).to.equal('No terms for now.') | 187 | expect(data.instance.terms).to.equal('No terms for now.') |
188 | expect(data.instance.defaultClientRoute).to.equal('/videos/trending') | ||
184 | expect(data.instance.customizations.css).to.be.empty | 189 | expect(data.instance.customizations.css).to.be.empty |
185 | expect(data.instance.customizations.javascript).to.be.empty | 190 | expect(data.instance.customizations.javascript).to.be.empty |
186 | expect(data.cache.previews.size).to.equal(1) | 191 | expect(data.cache.previews.size).to.equal(1) |