aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2021-01-27 17:15:21 +0100
committerChocobozzz <chocobozzz@cpy.re>2021-01-28 15:55:34 +0100
commitba5d4a849c7d7ba05f093480ae12286c4af61556 (patch)
tree704a80b96d3b437ad12feacaaaf58a96b97282a1 /server
parent3da68f0a781ebd893521e2e6fa200280c92ae815 (diff)
downloadPeerTube-ba5d4a849c7d7ba05f093480ae12286c4af61556.tar.gz
PeerTube-ba5d4a849c7d7ba05f093480ae12286c4af61556.tar.zst
PeerTube-ba5d4a849c7d7ba05f093480ae12286c4af61556.zip
move from trending routes to alg param
Diffstat (limited to 'server')
-rw-r--r--server/controllers/api/config.ts26
-rw-r--r--server/helpers/audit-logger.ts1
-rw-r--r--server/initializers/config.ts12
-rw-r--r--server/middlewares/validators/config.ts4
-rw-r--r--server/tests/api/check-params/config.ts14
-rw-r--r--server/tests/api/server/config.ts14
6 files changed, 37 insertions, 34 deletions
diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts
index 24e7601ec..45c03be24 100644
--- a/server/controllers/api/config.ts
+++ b/server/controllers/api/config.ts
@@ -68,12 +68,6 @@ async function getConfig (req: express.Request, res: express.Response) {
68 isNSFW: CONFIG.INSTANCE.IS_NSFW, 68 isNSFW: CONFIG.INSTANCE.IS_NSFW,
69 defaultNSFWPolicy: CONFIG.INSTANCE.DEFAULT_NSFW_POLICY, 69 defaultNSFWPolicy: CONFIG.INSTANCE.DEFAULT_NSFW_POLICY,
70 defaultClientRoute: CONFIG.INSTANCE.DEFAULT_CLIENT_ROUTE, 70 defaultClientRoute: CONFIG.INSTANCE.DEFAULT_CLIENT_ROUTE,
71 defaultTrendingRoute: CONFIG.INSTANCE.DEFAULT_TRENDING_ROUTE,
72 pages: {
73 hot: {
74 enabled: CONFIG.INSTANCE.PAGES.HOT.ENABLED
75 }
76 },
77 customizations: { 71 customizations: {
78 javascript: CONFIG.INSTANCE.CUSTOMIZATIONS.JAVASCRIPT, 72 javascript: CONFIG.INSTANCE.CUSTOMIZATIONS.JAVASCRIPT,
79 css: CONFIG.INSTANCE.CUSTOMIZATIONS.CSS 73 css: CONFIG.INSTANCE.CUSTOMIZATIONS.CSS
@@ -189,7 +183,11 @@ async function getConfig (req: express.Request, res: express.Response) {
189 }, 183 },
190 trending: { 184 trending: {
191 videos: { 185 videos: {
192 intervalDays: CONFIG.TRENDING.VIDEOS.INTERVAL_DAYS 186 intervalDays: CONFIG.TRENDING.VIDEOS.INTERVAL_DAYS,
187 algorithms: {
188 enabled: CONFIG.TRENDING.VIDEOS.ALGORITHMS.ENABLED,
189 default: CONFIG.TRENDING.VIDEOS.ALGORITHMS.DEFAULT
190 }
193 } 191 }
194 }, 192 },
195 tracker: { 193 tracker: {
@@ -371,12 +369,6 @@ function customConfig (): CustomConfig {
371 defaultNSFWPolicy: CONFIG.INSTANCE.DEFAULT_NSFW_POLICY, 369 defaultNSFWPolicy: CONFIG.INSTANCE.DEFAULT_NSFW_POLICY,
372 370
373 defaultClientRoute: CONFIG.INSTANCE.DEFAULT_CLIENT_ROUTE, 371 defaultClientRoute: CONFIG.INSTANCE.DEFAULT_CLIENT_ROUTE,
374 defaultTrendingRoute: CONFIG.INSTANCE.DEFAULT_TRENDING_ROUTE,
375 pages: {
376 hot: {
377 enabled: CONFIG.INSTANCE.PAGES.HOT.ENABLED
378 }
379 },
380 372
381 customizations: { 373 customizations: {
382 css: CONFIG.INSTANCE.CUSTOMIZATIONS.CSS, 374 css: CONFIG.INSTANCE.CUSTOMIZATIONS.CSS,
@@ -467,6 +459,14 @@ function customConfig (): CustomConfig {
467 } 459 }
468 } 460 }
469 }, 461 },
462 trending: {
463 videos: {
464 algorithms: {
465 enabled: CONFIG.TRENDING.VIDEOS.ALGORITHMS.ENABLED,
466 default: CONFIG.TRENDING.VIDEOS.ALGORITHMS.DEFAULT
467 }
468 }
469 },
470 autoBlacklist: { 470 autoBlacklist: {
471 videos: { 471 videos: {
472 ofUsers: { 472 ofUsers: {
diff --git a/server/helpers/audit-logger.ts b/server/helpers/audit-logger.ts
index e474959b2..6aae5e821 100644
--- a/server/helpers/audit-logger.ts
+++ b/server/helpers/audit-logger.ts
@@ -230,7 +230,6 @@ const customConfigKeysToKeep = [
230 'instance-description', 230 'instance-description',
231 'instance-terms', 231 'instance-terms',
232 'instance-defaultClientRoute', 232 'instance-defaultClientRoute',
233 'instance-defaultTrendingRoute',
234 'instance-defaultNSFWPolicy', 233 'instance-defaultNSFWPolicy',
235 'instance-customizations-javascript', 234 'instance-customizations-javascript',
236 'instance-customizations-css', 235 'instance-customizations-css',
diff --git a/server/initializers/config.ts b/server/initializers/config.ts
index e1f807752..fc4a8b709 100644
--- a/server/initializers/config.ts
+++ b/server/initializers/config.ts
@@ -110,7 +110,11 @@ const CONFIG = {
110 }, 110 },
111 TRENDING: { 111 TRENDING: {
112 VIDEOS: { 112 VIDEOS: {
113 INTERVAL_DAYS: config.get<number>('trending.videos.interval_days') 113 INTERVAL_DAYS: config.get<number>('trending.videos.interval_days'),
114 ALGORITHMS: {
115 get ENABLED () { return config.get<string[]>('trending.videos.algorithms.enabled') },
116 get DEFAULT () { return config.get<string>('trending.videos.algorithms.default') }
117 }
114 } 118 }
115 }, 119 },
116 REDUNDANCY: { 120 REDUNDANCY: {
@@ -281,12 +285,6 @@ const CONFIG = {
281 get DEFAULT_NSFW_POLICY () { return config.get<NSFWPolicyType>('instance.default_nsfw_policy') }, 285 get DEFAULT_NSFW_POLICY () { return config.get<NSFWPolicyType>('instance.default_nsfw_policy') },
282 286
283 get DEFAULT_CLIENT_ROUTE () { return config.get<string>('instance.default_client_route') }, 287 get DEFAULT_CLIENT_ROUTE () { return config.get<string>('instance.default_client_route') },
284 get DEFAULT_TRENDING_ROUTE () { return config.get<string>('instance.default_trending_route') },
285 PAGES: {
286 HOT: {
287 get ENABLED () { return config.get<boolean>('instance.pages.hot.enabled') }
288 }
289 },
290 288
291 CUSTOMIZATIONS: { 289 CUSTOMIZATIONS: {
292 get JAVASCRIPT () { return config.get<string>('instance.customizations.javascript') }, 290 get JAVASCRIPT () { return config.get<string>('instance.customizations.javascript') },
diff --git a/server/middlewares/validators/config.ts b/server/middlewares/validators/config.ts
index 0efe1157f..52c28799f 100644
--- a/server/middlewares/validators/config.ts
+++ b/server/middlewares/validators/config.ts
@@ -17,7 +17,6 @@ const customConfigUpdateValidator = [
17 body('instance.terms').exists().withMessage('Should have a valid instance terms'), 17 body('instance.terms').exists().withMessage('Should have a valid instance terms'),
18 body('instance.defaultNSFWPolicy').custom(isUserNSFWPolicyValid).withMessage('Should have a valid NSFW policy'), 18 body('instance.defaultNSFWPolicy').custom(isUserNSFWPolicyValid).withMessage('Should have a valid NSFW policy'),
19 body('instance.defaultClientRoute').exists().withMessage('Should have a valid instance default client route'), 19 body('instance.defaultClientRoute').exists().withMessage('Should have a valid instance default client route'),
20 body('instance.defaultTrendingRoute').exists().withMessage('Should have a valid instance default trending route'),
21 body('instance.customizations.css').exists().withMessage('Should have a valid instance CSS customization'), 20 body('instance.customizations.css').exists().withMessage('Should have a valid instance CSS customization'),
22 body('instance.customizations.javascript').exists().withMessage('Should have a valid instance JavaScript customization'), 21 body('instance.customizations.javascript').exists().withMessage('Should have a valid instance JavaScript customization'),
23 22
@@ -55,6 +54,9 @@ const customConfigUpdateValidator = [
55 body('import.videos.http.enabled').isBoolean().withMessage('Should have a valid import video http enabled boolean'), 54 body('import.videos.http.enabled').isBoolean().withMessage('Should have a valid import video http enabled boolean'),
56 body('import.videos.torrent.enabled').isBoolean().withMessage('Should have a valid import video torrent enabled boolean'), 55 body('import.videos.torrent.enabled').isBoolean().withMessage('Should have a valid import video torrent enabled boolean'),
57 56
57 body('trending.videos.algorithms.default').exists().withMessage('Should have a valid default trending algorithm'),
58 body('trending.videos.algorithms.enabled').exists().withMessage('Should have a valid array of enabled trending algorithms'),
59
58 body('followers.instance.enabled').isBoolean().withMessage('Should have a valid followers of instance boolean'), 60 body('followers.instance.enabled').isBoolean().withMessage('Should have a valid followers of instance boolean'),
59 body('followers.instance.manualApproval').isBoolean().withMessage('Should have a valid manual approval boolean'), 61 body('followers.instance.manualApproval').isBoolean().withMessage('Should have a valid manual approval boolean'),
60 62
diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.ts
index e58e0cd9f..d3ae5fe0a 100644
--- a/server/tests/api/check-params/config.ts
+++ b/server/tests/api/check-params/config.ts
@@ -44,12 +44,6 @@ describe('Test config API validators', function () {
44 defaultNSFWPolicy: 'blur', 44 defaultNSFWPolicy: 'blur',
45 45
46 defaultClientRoute: '/videos/recently-added', 46 defaultClientRoute: '/videos/recently-added',
47 defaultTrendingRoute: '/videos/trending',
48 pages: {
49 hot: {
50 enabled: true
51 }
52 },
53 47
54 customizations: { 48 customizations: {
55 javascript: 'alert("coucou")', 49 javascript: 'alert("coucou")',
@@ -142,6 +136,14 @@ describe('Test config API validators', function () {
142 } 136 }
143 } 137 }
144 }, 138 },
139 trending: {
140 videos: {
141 algorithms: {
142 enabled: [ 'hot', 'most-viewed', 'most-liked' ],
143 default: 'most-viewed'
144 }
145 }
146 },
145 autoBlacklist: { 147 autoBlacklist: {
146 videos: { 148 videos: {
147 ofUsers: { 149 ofUsers: {
diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.ts
index 328f4852a..e0575bdfd 100644
--- a/server/tests/api/server/config.ts
+++ b/server/tests/api/server/config.ts
@@ -276,12 +276,6 @@ describe('Test config', function () {
276 defaultNSFWPolicy: 'blur' as 'blur', 276 defaultNSFWPolicy: 'blur' as 'blur',
277 277
278 defaultClientRoute: '/videos/recently-added', 278 defaultClientRoute: '/videos/recently-added',
279 defaultTrendingRoute: '/videos/trending',
280 pages: {
281 hot: {
282 enabled: true
283 }
284 },
285 279
286 customizations: { 280 customizations: {
287 javascript: 'alert("coucou")', 281 javascript: 'alert("coucou")',
@@ -372,6 +366,14 @@ describe('Test config', function () {
372 } 366 }
373 } 367 }
374 }, 368 },
369 trending: {
370 videos: {
371 algorithms: {
372 enabled: [ 'hot', 'most-viewed', 'most-liked' ],
373 default: 'hot'
374 }
375 }
376 },
375 autoBlacklist: { 377 autoBlacklist: {
376 videos: { 378 videos: {
377 ofUsers: { 379 ofUsers: {