diff options
author | Chocobozzz <me@florianbigard.com> | 2018-09-11 16:27:07 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-09-13 14:05:49 +0200 |
commit | c48e82b5e0478434de30626d14594a97f2402e7c (patch) | |
tree | a78e5272bd0fe4f5b41831e571e02d05f1515b82 /server/initializers/checker.ts | |
parent | a651038487faa838bda3ce04695b08bc65baff70 (diff) | |
download | PeerTube-c48e82b5e0478434de30626d14594a97f2402e7c.tar.gz PeerTube-c48e82b5e0478434de30626d14594a97f2402e7c.tar.zst PeerTube-c48e82b5e0478434de30626d14594a97f2402e7c.zip |
Basic video redundancy implementation
Diffstat (limited to 'server/initializers/checker.ts')
-rw-r--r-- | server/initializers/checker.ts | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/server/initializers/checker.ts b/server/initializers/checker.ts index 9dd104035..6a2badd35 100644 --- a/server/initializers/checker.ts +++ b/server/initializers/checker.ts | |||
@@ -7,6 +7,9 @@ import { parse } from 'url' | |||
7 | import { CONFIG } from './constants' | 7 | import { CONFIG } from './constants' |
8 | import { logger } from '../helpers/logger' | 8 | import { logger } from '../helpers/logger' |
9 | import { getServerActor } from '../helpers/utils' | 9 | import { getServerActor } from '../helpers/utils' |
10 | import { VideosRedundancy } from '../../shared/models/redundancy' | ||
11 | import { isArray } from '../helpers/custom-validators/misc' | ||
12 | import { uniq } from 'lodash' | ||
10 | 13 | ||
11 | async function checkActivityPubUrls () { | 14 | async function checkActivityPubUrls () { |
12 | const actor = await getServerActor() | 15 | const actor = await getServerActor() |
@@ -35,6 +38,20 @@ function checkConfig () { | |||
35 | return 'NSFW policy setting should be "do_not_list" or "blur" or "display" instead of ' + defaultNSFWPolicy | 38 | return 'NSFW policy setting should be "do_not_list" or "blur" or "display" instead of ' + defaultNSFWPolicy |
36 | } | 39 | } |
37 | 40 | ||
41 | const redundancyVideos = config.get<VideosRedundancy[]>('redundancy.videos') | ||
42 | if (isArray(redundancyVideos)) { | ||
43 | for (const r of redundancyVideos) { | ||
44 | if ([ 'most-views' ].indexOf(r.strategy) === -1) { | ||
45 | return 'Redundancy video entries should have "most-views" strategy instead of ' + r.strategy | ||
46 | } | ||
47 | } | ||
48 | |||
49 | const filtered = uniq(redundancyVideos.map(r => r.strategy)) | ||
50 | if (filtered.length !== redundancyVideos.length) { | ||
51 | return 'Redundancy video entries should have uniq strategies' | ||
52 | } | ||
53 | } | ||
54 | |||
38 | return null | 55 | return null |
39 | } | 56 | } |
40 | 57 | ||