From 8c9e7875269a990ed3000e1d4995d808e4ff50f7 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 7 Apr 2020 15:27:41 +0200 Subject: Add ability to accept or not remote redundancies --- server/initializers/checker-after-init.ts | 8 ++++++++ server/initializers/checker-before-init.ts | 3 ++- server/initializers/config.ts | 6 ++++++ 3 files changed, 16 insertions(+), 1 deletion(-) (limited to 'server/initializers') diff --git a/server/initializers/checker-after-init.ts b/server/initializers/checker-after-init.ts index bc4aae957..a57d552df 100644 --- a/server/initializers/checker-after-init.ts +++ b/server/initializers/checker-after-init.ts @@ -11,6 +11,7 @@ import { RecentlyAddedStrategy } from '../../shared/models/redundancy' import { isArray } from '../helpers/custom-validators/misc' import { uniq } from 'lodash' import { WEBSERVER } from './constants' +import { VideoRedundancyConfigFilter } from '@shared/models/redundancy/video-redundancy-config-filter.type' async function checkActivityPubUrls () { const actor = await getServerActor() @@ -87,6 +88,13 @@ function checkConfig () { return 'Videos redundancy should be an array (you must uncomment lines containing - too)' } + // Remote redundancies + const acceptFrom = CONFIG.REMOTE_REDUNDANCY.VIDEOS.ACCEPT_FROM + const acceptFromValues = new Set([ 'nobody', 'anybody', 'followings' ]) + if (acceptFromValues.has(acceptFrom) === false) { + return 'remote_redundancy.videos.accept_from has an incorrect value' + } + // Check storage directory locations if (isProdInstance()) { const configStorage = config.get('storage') diff --git a/server/initializers/checker-before-init.ts b/server/initializers/checker-before-init.ts index a75f2cec2..064d89a4d 100644 --- a/server/initializers/checker-before-init.ts +++ b/server/initializers/checker-before-init.ts @@ -31,7 +31,8 @@ function checkMissedConfig () { 'tracker.enabled', 'tracker.private', 'tracker.reject_too_many_announces', 'history.videos.max_age', 'views.videos.remote.max_age', 'rates_limit.login.window', 'rates_limit.login.max', 'rates_limit.ask_send_email.window', 'rates_limit.ask_send_email.max', - 'theme.default' + 'theme.default', + 'remote_redundancy.videos.accept_from' ] const requiredAlternatives = [ [ // set diff --git a/server/initializers/config.ts b/server/initializers/config.ts index 3c07624e8..2c4d26a9e 100644 --- a/server/initializers/config.ts +++ b/server/initializers/config.ts @@ -5,6 +5,7 @@ import { VideosRedundancyStrategy } from '../../shared/models' import { buildPath, parseBytes, parseDurationToMs, root } from '../helpers/core-utils' import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' import * as bytes from 'bytes' +import { VideoRedundancyConfigFilter } from '@shared/models/redundancy/video-redundancy-config-filter.type' // Use a variable to reload the configuration if we need let config: IConfig = require('config') @@ -117,6 +118,11 @@ const CONFIG = { STRATEGIES: buildVideosRedundancy(config.get('redundancy.videos.strategies')) } }, + REMOTE_REDUNDANCY: { + VIDEOS: { + ACCEPT_FROM: config.get('remote_redundancy.videos.accept_from') + } + }, CSP: { ENABLED: config.get('csp.enabled'), REPORT_ONLY: config.get('csp.report_only'), -- cgit v1.2.3