aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/checker.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/initializers/checker.ts')
-rw-r--r--server/initializers/checker.ts13
1 files changed, 10 insertions, 3 deletions
diff --git a/server/initializers/checker.ts b/server/initializers/checker.ts
index 6048151a3..29f4f3036 100644
--- a/server/initializers/checker.ts
+++ b/server/initializers/checker.ts
@@ -7,7 +7,7 @@ import { parse } from 'url'
7import { CONFIG } from './constants' 7import { CONFIG } from './constants'
8import { logger } from '../helpers/logger' 8import { logger } from '../helpers/logger'
9import { getServerActor } from '../helpers/utils' 9import { getServerActor } from '../helpers/utils'
10import { VideosRedundancy } from '../../shared/models/redundancy' 10import { RecentlyAddedStrategy, VideosRedundancy } from '../../shared/models/redundancy'
11import { isArray } from '../helpers/custom-validators/misc' 11import { isArray } from '../helpers/custom-validators/misc'
12import { uniq } from 'lodash' 12import { uniq } from 'lodash'
13 13
@@ -34,24 +34,31 @@ async function checkActivityPubUrls () {
34function checkConfig () { 34function checkConfig () {
35 const defaultNSFWPolicy = config.get<string>('instance.default_nsfw_policy') 35 const defaultNSFWPolicy = config.get<string>('instance.default_nsfw_policy')
36 36
37 // NSFW policy
37 if ([ 'do_not_list', 'blur', 'display' ].indexOf(defaultNSFWPolicy) === -1) { 38 if ([ 'do_not_list', 'blur', 'display' ].indexOf(defaultNSFWPolicy) === -1) {
38 return 'NSFW policy setting should be "do_not_list" or "blur" or "display" instead of ' + defaultNSFWPolicy 39 return 'NSFW policy setting should be "do_not_list" or "blur" or "display" instead of ' + defaultNSFWPolicy
39 } 40 }
40 41
42 // Redundancies
41 const redundancyVideos = config.get<VideosRedundancy[]>('redundancy.videos') 43 const redundancyVideos = config.get<VideosRedundancy[]>('redundancy.videos')
42 if (isArray(redundancyVideos)) { 44 if (isArray(redundancyVideos)) {
43 for (const r of redundancyVideos) { 45 for (const r of redundancyVideos) {
44 if ([ 'most-views', 'trending' ].indexOf(r.strategy) === -1) { 46 if ([ 'most-views', 'trending', 'recently-added' ].indexOf(r.strategy) === -1) {
45 return 'Redundancy video entries should have "most-views" strategy instead of ' + r.strategy 47 return 'Redundancy video entries should have "most-views" strategy instead of ' + r.strategy
46 } 48 }
47 } 49 }
48 50
49 const filtered = uniq(redundancyVideos.map(r => r.strategy)) 51 const filtered = uniq(redundancyVideos.map(r => r.strategy))
50 if (filtered.length !== redundancyVideos.length) { 52 if (filtered.length !== redundancyVideos.length) {
51 return 'Redundancy video entries should have uniq strategies' 53 return 'Redundancy video entries should have unique strategies'
52 } 54 }
53 } 55 }
54 56
57 const recentlyAddedStrategy = redundancyVideos.find(r => r.strategy === 'recently-added') as RecentlyAddedStrategy
58 if (recentlyAddedStrategy && isNaN(recentlyAddedStrategy.minViews)) {
59 return 'Min views in recently added strategy is not a number'
60 }
61
55 return null 62 return null
56} 63}
57 64