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'
+import { BroadcastMessageLevel } from '@shared/models/server'
// Use a variable to reload the configuration if we need
let config: IConfig = require('config')
DB: config.has('redis.db') ? config.get<number>('redis.db') : null
},
SMTP: {
+ TRANSPORT: config.has('smtp.transport') ? config.get<string>('smtp.transport') : 'smtp',
+ SENDMAIL: config.has('smtp.sendmail') ? config.get<string>('smtp.sendmail') : null,
HOSTNAME: config.get<string>('smtp.hostname'),
PORT: config.get<number>('smtp.port'),
USERNAME: config.get<string>('smtp.username'),
STRATEGIES: buildVideosRedundancy(config.get<any[]>('redundancy.videos.strategies'))
}
},
+ REMOTE_REDUNDANCY: {
+ VIDEOS: {
+ ACCEPT_FROM: config.get<VideoRedundancyConfigFilter>('remote_redundancy.videos.accept_from')
+ }
+ },
CSP: {
ENABLED: config.get<boolean>('csp.enabled'),
REPORT_ONLY: config.get<boolean>('csp.report_only'),
IMPORT: {
VIDEOS: {
HTTP: {
- get ENABLED () { return config.get<boolean>('import.videos.http.enabled') }
+ get ENABLED () { return config.get<boolean>('import.videos.http.enabled') },
+ PROXY: {
+ get ENABLED () { return config.get<boolean>('import.videos.http.proxy.enabled') },
+ get URL () { return config.get<string>('import.videos.http.proxy.url') }
+ }
},
TORRENT: {
get ENABLED () { return config.get<boolean>('import.videos.torrent.enabled') }
},
THEME: {
get DEFAULT () { return config.get<string>('theme.default') }
+ },
+ BROADCAST_MESSAGE: {
+ get ENABLED () { return config.get<boolean>('broadcast_message.enabled') },
+ get MESSAGE () { return config.get<string>('broadcast_message.message') },
+ get LEVEL () { return config.get<BroadcastMessageLevel>('broadcast_message.level') },
+ get DISMISSABLE () { return config.get<boolean>('broadcast_message.dismissable') }
}
}
configChangedHandlers.push(fun)
}
+function isEmailEnabled () {
+ return !!CONFIG.SMTP.HOSTNAME && !!CONFIG.SMTP.PORT
+}
+
// ---------------------------------------------------------------------------
export {
CONFIG,
- registerConfigChangedHandler
+ registerConfigChangedHandler,
+ isEmailEnabled
}
// ---------------------------------------------------------------------------
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
function purge () {
for (const fileName in require.cache) {
- if (-1 === fileName.indexOf(directory())) {
+ if (fileName.includes(directory()) === false) {
continue
}