aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/api/config.ts63
-rw-r--r--server/controllers/static.ts5
2 files changed, 36 insertions, 32 deletions
diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts
index 81518bbb5..21fa85a08 100644
--- a/server/controllers/api/config.ts
+++ b/server/controllers/api/config.ts
@@ -4,7 +4,7 @@ import { ServerConfig, UserRight } from '../../../shared'
4import { About } from '../../../shared/models/server/about.model' 4import { About } from '../../../shared/models/server/about.model'
5import { CustomConfig } from '../../../shared/models/server/custom-config.model' 5import { CustomConfig } from '../../../shared/models/server/custom-config.model'
6import { isSignupAllowed, isSignupAllowedForCurrentIP } from '../../helpers/signup' 6import { isSignupAllowed, isSignupAllowedForCurrentIP } from '../../helpers/signup'
7import { CONSTRAINTS_FIELDS, DEFAULT_THEME_NAME } from '../../initializers/constants' 7import { CONSTRAINTS_FIELDS, DEFAULT_THEME_NAME, PEERTUBE_VERSION } from '../../initializers/constants'
8import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares' 8import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares'
9import { customConfigUpdateValidator } from '../../middlewares/validators/config' 9import { customConfigUpdateValidator } from '../../middlewares/validators/config'
10import { ClientHtml } from '../../lib/client-html' 10import { ClientHtml } from '../../lib/client-html'
@@ -18,7 +18,6 @@ import { CONFIG, reloadConfig } from '../../initializers/config'
18import { PluginManager } from '../../lib/plugins/plugin-manager' 18import { PluginManager } from '../../lib/plugins/plugin-manager'
19import { getThemeOrDefault } from '../../lib/plugins/theme-utils' 19import { getThemeOrDefault } from '../../lib/plugins/theme-utils'
20 20
21const packageJSON = require('../../../../package.json')
22const configRouter = express.Router() 21const configRouter = express.Router()
23 22
24const auditLogger = auditLoggerFactory('config') 23const auditLogger = auditLoggerFactory('config')
@@ -46,35 +45,14 @@ configRouter.delete('/custom',
46) 45)
47 46
48let serverCommit: string 47let serverCommit: string
48
49async function getConfig (req: express.Request, res: express.Response) { 49async function getConfig (req: express.Request, res: express.Response) {
50 const allowed = await isSignupAllowed() 50 const allowed = await isSignupAllowed()
51 const allowedForCurrentIP = isSignupAllowedForCurrentIP(req.ip) 51 const allowedForCurrentIP = isSignupAllowedForCurrentIP(req.ip)
52 const defaultTheme = getThemeOrDefault(CONFIG.THEME.DEFAULT, DEFAULT_THEME_NAME)
52 53
53 if (serverCommit === undefined) serverCommit = await getServerCommit() 54 if (serverCommit === undefined) serverCommit = await getServerCommit()
54 55
55 const enabledResolutions = Object.keys(CONFIG.TRANSCODING.RESOLUTIONS)
56 .filter(key => CONFIG.TRANSCODING.ENABLED && CONFIG.TRANSCODING.RESOLUTIONS[key] === true)
57 .map(r => parseInt(r, 10))
58
59 const registeredPlugins = PluginManager.Instance.getRegisteredPlugins()
60 .map(p => ({
61 name: p.name,
62 version: p.version,
63 description: p.description,
64 clientScripts: p.clientScripts
65 }))
66
67 const registeredThemes = PluginManager.Instance.getRegisteredThemes()
68 .map(t => ({
69 name: t.name,
70 version: t.version,
71 description: t.description,
72 css: t.css,
73 clientScripts: t.clientScripts
74 }))
75
76 const defaultTheme = getThemeOrDefault(CONFIG.THEME.DEFAULT, DEFAULT_THEME_NAME)
77
78 const json: ServerConfig = { 56 const json: ServerConfig = {
79 instance: { 57 instance: {
80 name: CONFIG.INSTANCE.NAME, 58 name: CONFIG.INSTANCE.NAME,
@@ -88,10 +66,10 @@ async function getConfig (req: express.Request, res: express.Response) {
88 } 66 }
89 }, 67 },
90 plugin: { 68 plugin: {
91 registered: registeredPlugins 69 registered: getRegisteredPlugins()
92 }, 70 },
93 theme: { 71 theme: {
94 registered: registeredThemes, 72 registered: getRegisteredThemes(),
95 default: defaultTheme 73 default: defaultTheme
96 }, 74 },
97 email: { 75 email: {
@@ -100,7 +78,7 @@ async function getConfig (req: express.Request, res: express.Response) {
100 contactForm: { 78 contactForm: {
101 enabled: CONFIG.CONTACT_FORM.ENABLED 79 enabled: CONFIG.CONTACT_FORM.ENABLED
102 }, 80 },
103 serverVersion: packageJSON.version, 81 serverVersion: PEERTUBE_VERSION,
104 serverCommit, 82 serverCommit,
105 signup: { 83 signup: {
106 allowed, 84 allowed,
@@ -111,7 +89,7 @@ async function getConfig (req: express.Request, res: express.Response) {
111 hls: { 89 hls: {
112 enabled: CONFIG.TRANSCODING.HLS.ENABLED 90 enabled: CONFIG.TRANSCODING.HLS.ENABLED
113 }, 91 },
114 enabledResolutions 92 enabledResolutions: getEnabledResolutions()
115 }, 93 },
116 import: { 94 import: {
117 videos: { 95 videos: {
@@ -342,3 +320,30 @@ function convertCustomConfigBody (body: CustomConfig) {
342 320
343 return objectConverter(body, keyConverter, valueConverter) 321 return objectConverter(body, keyConverter, valueConverter)
344} 322}
323
324function getRegisteredThemes () {
325 return PluginManager.Instance.getRegisteredThemes()
326 .map(t => ({
327 name: t.name,
328 version: t.version,
329 description: t.description,
330 css: t.css,
331 clientScripts: t.clientScripts
332 }))
333}
334
335function getEnabledResolutions () {
336 return Object.keys(CONFIG.TRANSCODING.RESOLUTIONS)
337 .filter(key => CONFIG.TRANSCODING.ENABLED && CONFIG.TRANSCODING.RESOLUTIONS[ key ] === true)
338 .map(r => parseInt(r, 10))
339}
340
341function getRegisteredPlugins () {
342 return PluginManager.Instance.getRegisteredPlugins()
343 .map(p => ({
344 name: p.name,
345 version: p.version,
346 description: p.description,
347 clientScripts: p.clientScripts
348 }))
349}
diff --git a/server/controllers/static.ts b/server/controllers/static.ts
index a6b462443..af7de562a 100644
--- a/server/controllers/static.ts
+++ b/server/controllers/static.ts
@@ -1,7 +1,7 @@
1import * as cors from 'cors' 1import * as cors from 'cors'
2import * as express from 'express' 2import * as express from 'express'
3import { 3import {
4 HLS_STREAMING_PLAYLIST_DIRECTORY, 4 HLS_STREAMING_PLAYLIST_DIRECTORY, PEERTUBE_VERSION,
5 ROUTE_CACHE_LIFETIME, 5 ROUTE_CACHE_LIFETIME,
6 STATIC_DOWNLOAD_PATHS, 6 STATIC_DOWNLOAD_PATHS,
7 STATIC_MAX_AGE, 7 STATIC_MAX_AGE,
@@ -19,7 +19,6 @@ import { join } from 'path'
19import { root } from '../helpers/core-utils' 19import { root } from '../helpers/core-utils'
20import { CONFIG } from '../initializers/config' 20import { CONFIG } from '../initializers/config'
21 21
22const packageJSON = require('../../../package.json')
23const staticRouter = express.Router() 22const staticRouter = express.Router()
24 23
25staticRouter.use(cors()) 24staticRouter.use(cors())
@@ -205,7 +204,7 @@ async function generateNodeinfo (req: express.Request, res: express.Response) {
205 version: '2.0', 204 version: '2.0',
206 software: { 205 software: {
207 name: 'peertube', 206 name: 'peertube',
208 version: packageJSON.version 207 version: PEERTUBE_VERSION
209 }, 208 },
210 protocols: [ 209 protocols: [
211 'activitypub' 210 'activitypub'