From c48e82b5e0478434de30626d14594a97f2402e7c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 11 Sep 2018 16:27:07 +0200 Subject: Basic video redundancy implementation --- server/initializers/checker.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'server/initializers/checker.ts') 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' import { CONFIG } from './constants' import { logger } from '../helpers/logger' import { getServerActor } from '../helpers/utils' +import { VideosRedundancy } from '../../shared/models/redundancy' +import { isArray } from '../helpers/custom-validators/misc' +import { uniq } from 'lodash' async function checkActivityPubUrls () { const actor = await getServerActor() @@ -35,6 +38,20 @@ function checkConfig () { return 'NSFW policy setting should be "do_not_list" or "blur" or "display" instead of ' + defaultNSFWPolicy } + const redundancyVideos = config.get('redundancy.videos') + if (isArray(redundancyVideos)) { + for (const r of redundancyVideos) { + if ([ 'most-views' ].indexOf(r.strategy) === -1) { + return 'Redundancy video entries should have "most-views" strategy instead of ' + r.strategy + } + } + + const filtered = uniq(redundancyVideos.map(r => r.strategy)) + if (filtered.length !== redundancyVideos.length) { + return 'Redundancy video entries should have uniq strategies' + } + } + return null } -- cgit v1.2.3