aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/config.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/config.ts')
-rw-r--r--server/lib/config.ts31
1 files changed, 20 insertions, 11 deletions
diff --git a/server/lib/config.ts b/server/lib/config.ts
index fed468fe1..18d49f05a 100644
--- a/server/lib/config.ts
+++ b/server/lib/config.ts
@@ -2,17 +2,13 @@ import { isSignupAllowed, isSignupAllowedForCurrentIP } from '@server/helpers/si
2import { getServerCommit } from '@server/helpers/utils' 2import { getServerCommit } from '@server/helpers/utils'
3import { CONFIG, isEmailEnabled } from '@server/initializers/config' 3import { CONFIG, isEmailEnabled } from '@server/initializers/config'
4import { CONSTRAINTS_FIELDS, DEFAULT_THEME_NAME, PEERTUBE_VERSION } from '@server/initializers/constants' 4import { CONSTRAINTS_FIELDS, DEFAULT_THEME_NAME, PEERTUBE_VERSION } from '@server/initializers/constants'
5import { RegisteredExternalAuthConfig, RegisteredIdAndPassAuthConfig, ServerConfig } from '@shared/models' 5import { HTMLServerConfig, RegisteredExternalAuthConfig, RegisteredIdAndPassAuthConfig, ServerConfig } from '@shared/models'
6import { Hooks } from './plugins/hooks' 6import { Hooks } from './plugins/hooks'
7import { PluginManager } from './plugins/plugin-manager' 7import { PluginManager } from './plugins/plugin-manager'
8import { getThemeOrDefault } from './plugins/theme-utils' 8import { getThemeOrDefault } from './plugins/theme-utils'
9import { VideoTranscodingProfilesManager } from './transcoding/video-transcoding-profiles' 9import { VideoTranscodingProfilesManager } from './transcoding/video-transcoding-profiles'
10 10
11let serverCommit: string
12
13async function getServerConfig (ip?: string): Promise<ServerConfig> { 11async function getServerConfig (ip?: string): Promise<ServerConfig> {
14 if (serverCommit === undefined) serverCommit = await getServerCommit()
15
16 const { allowed } = await Hooks.wrapPromiseFun( 12 const { allowed } = await Hooks.wrapPromiseFun(
17 isSignupAllowed, 13 isSignupAllowed,
18 { 14 {
@@ -22,6 +18,23 @@ async function getServerConfig (ip?: string): Promise<ServerConfig> {
22 ) 18 )
23 19
24 const allowedForCurrentIP = isSignupAllowedForCurrentIP(ip) 20 const allowedForCurrentIP = isSignupAllowedForCurrentIP(ip)
21
22 const signup = {
23 allowed,
24 allowedForCurrentIP,
25 requiresEmailVerification: CONFIG.SIGNUP.REQUIRES_EMAIL_VERIFICATION
26 }
27
28 const htmlConfig = await getHTMLServerConfig()
29
30 return { ...htmlConfig, signup }
31}
32
33// Config injected in HTML
34let serverCommit: string
35async function getHTMLServerConfig (): Promise<HTMLServerConfig> {
36 if (serverCommit === undefined) serverCommit = await getServerCommit()
37
25 const defaultTheme = getThemeOrDefault(CONFIG.THEME.DEFAULT, DEFAULT_THEME_NAME) 38 const defaultTheme = getThemeOrDefault(CONFIG.THEME.DEFAULT, DEFAULT_THEME_NAME)
26 39
27 return { 40 return {
@@ -65,11 +78,6 @@ async function getServerConfig (ip?: string): Promise<ServerConfig> {
65 }, 78 },
66 serverVersion: PEERTUBE_VERSION, 79 serverVersion: PEERTUBE_VERSION,
67 serverCommit, 80 serverCommit,
68 signup: {
69 allowed,
70 allowedForCurrentIP,
71 requiresEmailVerification: CONFIG.SIGNUP.REQUIRES_EMAIL_VERIFICATION
72 },
73 transcoding: { 81 transcoding: {
74 hls: { 82 hls: {
75 enabled: CONFIG.TRANSCODING.HLS.ENABLED 83 enabled: CONFIG.TRANSCODING.HLS.ENABLED
@@ -223,7 +231,8 @@ export {
223 getServerConfig, 231 getServerConfig,
224 getRegisteredThemes, 232 getRegisteredThemes,
225 getEnabledResolutions, 233 getEnabledResolutions,
226 getRegisteredPlugins 234 getRegisteredPlugins,
235 getHTMLServerConfig
227} 236}
228 237
229// --------------------------------------------------------------------------- 238// ---------------------------------------------------------------------------