X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Finitializers%2Fconfig.ts;h=fb6f7ae62dec5008cae94a8c61afbf902cd9b193;hb=8f7d35fd0fa900fc94c035b5d7d608bf733e6d10;hp=3a7c72a1caf376e71cdc61d619c23f5ec40e6ff7;hpb=97b6428af78d7b00d9b57e1a317d1355f5e76939;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/initializers/config.ts b/server/initializers/config.ts index 3a7c72a1c..fb6f7ae62 100644 --- a/server/initializers/config.ts +++ b/server/initializers/config.ts @@ -1,13 +1,13 @@ import bytes from 'bytes' import { IConfig } from 'config' -import decache from 'decache' import { dirname, join } from 'path' +import { decacheModule } from '@server/helpers/decache' import { VideoRedundancyConfigFilter } from '@shared/models/redundancy/video-redundancy-config-filter.type' import { BroadcastMessageLevel } from '@shared/models/server' -import { VideosRedundancyStrategy } from '../../shared/models' +import { VideoPrivacy, VideosRedundancyStrategy } from '../../shared/models' import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type' -// Do not use barrels, remain constants as independent as possible -import { buildPath, parseBytes, parseDurationToMs, root } from '../helpers/core-utils' +import { buildPath, root } from '../../shared/core-utils' +import { parseBytes, parseDurationToMs } from '../helpers/core-utils' // Use a variable to reload the configuration if we need let config: IConfig = require('config') @@ -64,11 +64,34 @@ const CONFIG = { MINIATURE: { get PREFER_AUTHOR_DISPLAY_NAME () { return config.get('client.videos.miniature.prefer_author_display_name') } } + }, + MENU: { + LOGIN: { + get REDIRECT_ON_SINGLE_EXTERNAL_AUTH () { return config.get('client.menu.login.redirect_on_single_external_auth') } + } + } + }, + + DEFAULTS: { + PUBLISH: { + DOWNLOAD_ENABLED: config.get('defaults.publish.download_enabled'), + COMMENTS_ENABLED: config.get('defaults.publish.comments_enabled'), + PRIVACY: config.get('defaults.publish.privacy'), + LICENCE: config.get('defaults.publish.licence') + }, + P2P: { + WEBAPP: { + ENABLED: config.get('defaults.p2p.webapp.enabled') + }, + EMBED: { + ENABLED: config.get('defaults.p2p.embed.enabled') + } } }, STORAGE: { TMP_DIR: buildPath(config.get('storage.tmp')), + BIN_DIR: buildPath(config.get('storage.bin')), ACTOR_IMAGES: buildPath(config.get('storage.avatars')), LOG_DIR: buildPath(config.get('storage.logs')), VIDEOS_DIR: buildPath(config.get('storage.videos')), @@ -182,7 +205,9 @@ const CONFIG = { VIDEOS: { REMOTE: { MAX_AGE: parseDurationToMs(config.get('views.videos.remote.max_age')) - } + }, + LOCAL_BUFFER_UPDATE_INTERVAL: parseDurationToMs(config.get('views.videos.local_buffer_update_interval')), + IP_VIEW_EXPIRATION: parseDurationToMs(config.get('views.videos.ip_view_expiration')) } }, PLUGINS: { @@ -233,6 +258,9 @@ const CONFIG = { get VIDEO_QUOTA () { return parseBytes(config.get('user.video_quota')) }, get VIDEO_QUOTA_DAILY () { return parseBytes(config.get('user.video_quota_daily')) } }, + VIDEO_CHANNELS: { + get MAX_PER_USER () { return config.get('video_channels.max_per_user') } + }, TRANSCODING: { get ENABLED () { return config.get('transcoding.enabled') }, get ALLOW_ADDITIONAL_EXTENSIONS () { return config.get('transcoding.allow_additional_extensions') }, @@ -242,6 +270,7 @@ const CONFIG = { get PROFILE () { return config.get('transcoding.profile') }, RESOLUTIONS: { get '0p' () { return config.get('transcoding.resolutions.0p') }, + get '144p' () { return config.get('transcoding.resolutions.144p') }, get '240p' () { return config.get('transcoding.resolutions.240p') }, get '360p' () { return config.get('transcoding.resolutions.360p') }, get '480p' () { return config.get('transcoding.resolutions.480p') }, @@ -267,15 +296,24 @@ const CONFIG = { get ALLOW_REPLAY () { return config.get('live.allow_replay') }, RTMP: { + get ENABLED () { return config.get('live.rtmp.enabled') }, get PORT () { return config.get('live.rtmp.port') } }, + RTMPS: { + get ENABLED () { return config.get('live.rtmps.enabled') }, + get PORT () { return config.get('live.rtmps.port') }, + get KEY_FILE () { return config.get('live.rtmps.key_file') }, + get CERT_FILE () { return config.get('live.rtmps.cert_file') } + }, + TRANSCODING: { get ENABLED () { return config.get('live.transcoding.enabled') }, get THREADS () { return config.get('live.transcoding.threads') }, get PROFILE () { return config.get('live.transcoding.profile') }, RESOLUTIONS: { + get '144p' () { return config.get('live.transcoding.resolutions.144p') }, get '240p' () { return config.get('live.transcoding.resolutions.240p') }, get '360p' () { return config.get('live.transcoding.resolutions.360p') }, get '480p' () { return config.get('live.transcoding.resolutions.480p') }, @@ -292,11 +330,14 @@ const CONFIG = { HTTP: { get ENABLED () { return config.get('import.videos.http.enabled') }, - get FORCE_IPV4 () { return config.get('import.videos.http.force_ipv4') }, - PROXY: { - get ENABLED () { return config.get('import.videos.http.proxy.enabled') }, - get URL () { return config.get('import.videos.http.proxy.url') } - } + + YOUTUBE_DL_RELEASE: { + get URL () { return config.get('import.videos.http.youtube_dl_release.url') }, + get NAME () { return config.get('import.videos.http.youtube_dl_release.name') }, + get PYTHON_PATH () { return config.get('import.videos.http.youtube_dl_release.python_path') } + }, + + get FORCE_IPV4 () { return config.get('import.videos.http.force_ipv4') } }, TORRENT: { get ENABLED () { return config.get('import.videos.torrent.enabled') } @@ -480,7 +521,7 @@ export function reloadConfig () { delete require.cache[fileName] } - decache('config') + decacheModule('config') } purge()