aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2019-12-17 13:07:50 +0100
committerRigel Kent <sendmemail@rigelk.eu>2019-12-17 13:07:50 +0100
commit174e0855873d7086ad8240599101c2f717ebbd59 (patch)
tree4b698eb1dddb5e94dd2808871da0c6e538344ef8 /server
parent208c7e92e9337a01ac2915a2e2d9c3067af32377 (diff)
downloadPeerTube-174e0855873d7086ad8240599101c2f717ebbd59.tar.gz
PeerTube-174e0855873d7086ad8240599101c2f717ebbd59.tar.zst
PeerTube-174e0855873d7086ad8240599101c2f717ebbd59.zip
(nodeinfo) add server config to the nodeinfo metadata
Diffstat (limited to 'server')
-rw-r--r--server/controllers/api/config.ts59
-rw-r--r--server/controllers/static.ts89
2 files changed, 118 insertions, 30 deletions
diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts
index c593fa302..b2f23c1b0 100644
--- a/server/controllers/api/config.ts
+++ b/server/controllers/api/config.ts
@@ -227,10 +227,40 @@ async function updateCustomConfig (req: express.Request, res: express.Response)
227 return res.json(data).end() 227 return res.json(data).end()
228} 228}
229 229
230function getRegisteredThemes () {
231 return PluginManager.Instance.getRegisteredThemes()
232 .map(t => ({
233 name: t.name,
234 version: t.version,
235 description: t.description,
236 css: t.css,
237 clientScripts: t.clientScripts
238 }))
239}
240
241function getEnabledResolutions () {
242 return Object.keys(CONFIG.TRANSCODING.RESOLUTIONS)
243 .filter(key => CONFIG.TRANSCODING.ENABLED && CONFIG.TRANSCODING.RESOLUTIONS[ key ] === true)
244 .map(r => parseInt(r, 10))
245}
246
247function getRegisteredPlugins () {
248 return PluginManager.Instance.getRegisteredPlugins()
249 .map(p => ({
250 name: p.name,
251 version: p.version,
252 description: p.description,
253 clientScripts: p.clientScripts
254 }))
255}
256
230// --------------------------------------------------------------------------- 257// ---------------------------------------------------------------------------
231 258
232export { 259export {
233 configRouter 260 configRouter,
261 getEnabledResolutions,
262 getRegisteredPlugins,
263 getRegisteredThemes
234} 264}
235 265
236// --------------------------------------------------------------------------- 266// ---------------------------------------------------------------------------
@@ -370,30 +400,3 @@ function convertCustomConfigBody (body: CustomConfig) {
370 400
371 return objectConverter(body, keyConverter, valueConverter) 401 return objectConverter(body, keyConverter, valueConverter)
372} 402}
373
374function getRegisteredThemes () {
375 return PluginManager.Instance.getRegisteredThemes()
376 .map(t => ({
377 name: t.name,
378 version: t.version,
379 description: t.description,
380 css: t.css,
381 clientScripts: t.clientScripts
382 }))
383}
384
385function getEnabledResolutions () {
386 return Object.keys(CONFIG.TRANSCODING.RESOLUTIONS)
387 .filter(key => CONFIG.TRANSCODING.ENABLED && CONFIG.TRANSCODING.RESOLUTIONS[ key ] === true)
388 .map(r => parseInt(r, 10))
389}
390
391function getRegisteredPlugins () {
392 return PluginManager.Instance.getRegisteredPlugins()
393 .map(p => ({
394 name: p.name,
395 version: p.version,
396 description: p.description,
397 clientScripts: p.clientScripts
398 }))
399}
diff --git a/server/controllers/static.ts b/server/controllers/static.ts
index 0aab12756..f86a0cb5b 100644
--- a/server/controllers/static.ts
+++ b/server/controllers/static.ts
@@ -7,7 +7,9 @@ import {
7 STATIC_DOWNLOAD_PATHS, 7 STATIC_DOWNLOAD_PATHS,
8 STATIC_MAX_AGE, 8 STATIC_MAX_AGE,
9 STATIC_PATHS, 9 STATIC_PATHS,
10 WEBSERVER 10 WEBSERVER,
11 CONSTRAINTS_FIELDS,
12 DEFAULT_THEME_NAME
11} from '../initializers/constants' 13} from '../initializers/constants'
12import { cacheRoute } from '../middlewares/cache' 14import { cacheRoute } from '../middlewares/cache'
13import { asyncMiddleware, videosDownloadValidator } from '../middlewares' 15import { asyncMiddleware, videosDownloadValidator } from '../middlewares'
@@ -18,10 +20,13 @@ import { HttpNodeinfoDiasporaSoftwareNsSchema20 } from '../../shared/models/node
18import { join } from 'path' 20import { join } from 'path'
19import { root } from '../helpers/core-utils' 21import { root } from '../helpers/core-utils'
20import { CONFIG } from '../initializers/config' 22import { CONFIG } from '../initializers/config'
23import { Emailer } from '../lib/emailer'
21import { getPreview, getVideoCaption } from './lazy-static' 24import { getPreview, getVideoCaption } from './lazy-static'
22import { VideoStreamingPlaylistType } from '@shared/models/videos/video-streaming-playlist.type' 25import { VideoStreamingPlaylistType } from '@shared/models/videos/video-streaming-playlist.type'
23import { MVideoFile, MVideoFullLight } from '@server/typings/models' 26import { MVideoFile, MVideoFullLight } from '@server/typings/models'
24import { getTorrentFilePath, getVideoFilePath } from '@server/lib/video-paths' 27import { getTorrentFilePath, getVideoFilePath } from '@server/lib/video-paths'
28import { getThemeOrDefault } from '../lib/plugins/theme-utils'
29import { getEnabledResolutions, getRegisteredPlugins, getRegisteredThemes } from '@server/controllers/api/config'
25 30
26const staticRouter = express.Router() 31const staticRouter = express.Router()
27 32
@@ -228,7 +233,87 @@ async function generateNodeinfo (req: express.Request, res: express.Response) {
228 postsName: 'Videos' 233 postsName: 'Videos'
229 }, 234 },
230 nodeName: CONFIG.INSTANCE.NAME, 235 nodeName: CONFIG.INSTANCE.NAME,
231 nodeDescription: CONFIG.INSTANCE.SHORT_DESCRIPTION 236 nodeDescription: CONFIG.INSTANCE.SHORT_DESCRIPTION,
237 nodeConfig: {
238 plugin: {
239 registered: getRegisteredPlugins()
240 },
241 theme: {
242 registered: getRegisteredThemes(),
243 default: getThemeOrDefault(CONFIG.THEME.DEFAULT, DEFAULT_THEME_NAME)
244 },
245 email: {
246 enabled: Emailer.isEnabled()
247 },
248 contactForm: {
249 enabled: CONFIG.CONTACT_FORM.ENABLED
250 },
251 transcoding: {
252 hls: {
253 enabled: CONFIG.TRANSCODING.HLS.ENABLED
254 },
255 webtorrent: {
256 enabled: CONFIG.TRANSCODING.WEBTORRENT.ENABLED
257 },
258 enabledResolutions: getEnabledResolutions()
259 },
260 import: {
261 videos: {
262 http: {
263 enabled: CONFIG.IMPORT.VIDEOS.HTTP.ENABLED
264 },
265 torrent: {
266 enabled: CONFIG.IMPORT.VIDEOS.TORRENT.ENABLED
267 }
268 }
269 },
270 autoBlacklist: {
271 videos: {
272 ofUsers: {
273 enabled: CONFIG.AUTO_BLACKLIST.VIDEOS.OF_USERS.ENABLED
274 }
275 }
276 },
277 avatar: {
278 file: {
279 size: {
280 max: CONSTRAINTS_FIELDS.ACTORS.AVATAR.FILE_SIZE.max
281 },
282 extensions: CONSTRAINTS_FIELDS.ACTORS.AVATAR.EXTNAME
283 }
284 },
285 video: {
286 image: {
287 extensions: CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME,
288 size: {
289 max: CONSTRAINTS_FIELDS.VIDEOS.IMAGE.FILE_SIZE.max
290 }
291 },
292 file: {
293 extensions: CONSTRAINTS_FIELDS.VIDEOS.EXTNAME
294 }
295 },
296 videoCaption: {
297 file: {
298 size: {
299 max: CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.FILE_SIZE.max
300 },
301 extensions: CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.EXTNAME
302 }
303 },
304 user: {
305 videoQuota: CONFIG.USER.VIDEO_QUOTA,
306 videoQuotaDaily: CONFIG.USER.VIDEO_QUOTA_DAILY
307 },
308 trending: {
309 videos: {
310 intervalDays: CONFIG.TRENDING.VIDEOS.INTERVAL_DAYS
311 }
312 },
313 tracker: {
314 enabled: CONFIG.TRACKER.ENABLED
315 }
316 }
232 } 317 }
233 } as HttpNodeinfoDiasporaSoftwareNsSchema20 318 } as HttpNodeinfoDiasporaSoftwareNsSchema20
234 res.contentType('application/json; profile="http://nodeinfo.diaspora.software/ns/schema/2.0#"') 319 res.contentType('application/json; profile="http://nodeinfo.diaspora.software/ns/schema/2.0#"')