X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Finitializers%2Fconfig.ts;h=2c4d26a9e4e2f04d13ed972f43c0d1cc25fbe859;hb=4d9ae8f7cfce66ba0568a25c28034a2cad120444;hp=164d714d6b94ad7fd4edd10da4324334f087830f;hpb=8d5e65349deebd499c0be10fe02d535a77d58ddb;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/initializers/config.ts b/server/initializers/config.ts index 164d714d6..2c4d26a9e 100644 --- a/server/initializers/config.ts +++ b/server/initializers/config.ts @@ -1,10 +1,11 @@ import { IConfig } from 'config' import { dirname, join } from 'path' -import { VideosRedundancy } from '../../shared/models' +import { VideosRedundancyStrategy } from '../../shared/models' // Do not use barrels, remain constants as independent as possible 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') @@ -93,7 +94,12 @@ const CONFIG = { TRUST_PROXY: config.get('trust_proxy'), LOG: { LEVEL: config.get('log.level'), - ROTATION: config.get('log.rotation.enabled') + ROTATION: { + ENABLED: config.get('log.rotation.enabled'), + MAX_FILE_SIZE: bytes.parse(config.get('log.rotation.maxFileSize')), + MAX_FILES: config.get('log.rotation.maxFiles') + }, + ANONYMIZE_IP: config.get('log.anonymizeIP') }, SEARCH: { REMOTE_URI: { @@ -112,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'), @@ -168,6 +179,7 @@ const CONFIG = { get ALLOW_AUDIO_FILES () { return config.get('transcoding.allow_audio_files') }, get THREADS () { return config.get('transcoding.threads') }, RESOLUTIONS: { + get '0p' () { return config.get('transcoding.resolutions.0p') }, get '240p' () { return config.get('transcoding.resolutions.240p') }, get '360p' () { return config.get('transcoding.resolutions.360p') }, get '480p' () { return config.get('transcoding.resolutions.480p') }, @@ -177,12 +189,19 @@ const CONFIG = { }, HLS: { get ENABLED () { return config.get('transcoding.hls.enabled') } + }, + WEBTORRENT: { + get ENABLED () { return config.get('transcoding.webtorrent.enabled') } } }, IMPORT: { VIDEOS: { HTTP: { - get ENABLED () { return config.get('import.videos.http.enabled') } + get ENABLED () { return config.get('import.videos.http.enabled') }, + PROXY: { + get ENABLED () { return config.get('import.videos.http.proxy.enabled') }, + get URL () { return config.get('import.videos.http.proxy.url') } + } }, TORRENT: { get ENABLED () { return config.get('import.videos.torrent.enabled') } @@ -271,11 +290,16 @@ function registerConfigChangedHandler (fun: Function) { configChangedHandlers.push(fun) } +function isEmailEnabled () { + return !!CONFIG.SMTP.HOSTNAME && !!CONFIG.SMTP.PORT +} + // --------------------------------------------------------------------------- export { CONFIG, - registerConfigChangedHandler + registerConfigChangedHandler, + isEmailEnabled } // --------------------------------------------------------------------------- @@ -288,10 +312,10 @@ function getLocalConfigFilePath () { if (process.env.NODE_ENV) filename += `-${process.env.NODE_ENV}` if (process.env.NODE_APP_INSTANCE) filename += `-${process.env.NODE_APP_INSTANCE}` - return join(dirname(configSources[ 0 ].name), filename + '.json') + return join(dirname(configSources[0].name), filename + '.json') } -function buildVideosRedundancy (objs: any[]): VideosRedundancy[] { +function buildVideosRedundancy (objs: any[]): VideosRedundancyStrategy[] { if (!objs) return [] if (!Array.isArray(objs)) return objs @@ -317,7 +341,7 @@ export function reloadConfig () { function purge () { for (const fileName in require.cache) { - if (-1 === fileName.indexOf(directory())) { + if (fileName.includes(directory()) === false) { continue }