X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fcontrollers%2Fapi%2Fconfig.ts;h=86434f382fbf24799fa2a331425449ca131727ab;hb=e364e31e25bd1d4b8d801c845a96d6be708f0a18;hp=5ce7adc35e25972cd4d8b9ec068048a8d8f85e7a;hpb=96d52038788dda2f479362ce8e980f895369eec7;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts index 5ce7adc35..86434f382 100644 --- a/server/controllers/api/config.ts +++ b/server/controllers/api/config.ts @@ -1,49 +1,56 @@ -import * as express from 'express' +import express from 'express' import { remove, writeJSON } from 'fs-extra' import { snakeCase } from 'lodash' import validator from 'validator' -import { getServerConfig } from '@server/lib/config' -import { UserRight } from '../../../shared' -import { About } from '../../../shared/models/server/about.model' -import { CustomConfig } from '../../../shared/models/server/custom-config.model' +import { ServerConfigManager } from '@server/lib/server-config-manager' +import { About, CustomConfig, UserRight } from '@shared/models' import { auditLoggerFactory, CustomConfigAuditView, getAuditIdFromRes } from '../../helpers/audit-logger' import { objectConverter } from '../../helpers/core-utils' import { CONFIG, reloadConfig } from '../../initializers/config' import { ClientHtml } from '../../lib/client-html' -import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares' -import { customConfigUpdateValidator } from '../../middlewares/validators/config' +import { asyncMiddleware, authenticate, ensureUserHasRight, openapiOperationDoc } from '../../middlewares' +import { customConfigUpdateValidator, ensureConfigIsEditable } from '../../middlewares/validators/config' const configRouter = express.Router() const auditLogger = auditLoggerFactory('config') -configRouter.get('/about', getAbout) - configRouter.get('/', + openapiOperationDoc({ operationId: 'getConfig' }), asyncMiddleware(getConfig) ) +configRouter.get('/about', + openapiOperationDoc({ operationId: 'getAbout' }), + getAbout +) + configRouter.get('/custom', + openapiOperationDoc({ operationId: 'getCustomConfig' }), authenticate, ensureUserHasRight(UserRight.MANAGE_CONFIGURATION), getCustomConfig ) configRouter.put('/custom', + openapiOperationDoc({ operationId: 'putCustomConfig' }), authenticate, ensureUserHasRight(UserRight.MANAGE_CONFIGURATION), + ensureConfigIsEditable, customConfigUpdateValidator, asyncMiddleware(updateCustomConfig) ) configRouter.delete('/custom', + openapiOperationDoc({ operationId: 'delCustomConfig' }), authenticate, ensureUserHasRight(UserRight.MANAGE_CONFIGURATION), + ensureConfigIsEditable, asyncMiddleware(deleteCustomConfig) ) async function getConfig (req: express.Request, res: express.Response) { - const json = await getServerConfig(req.ip) + const json = await ServerConfigManager.Instance.getServerConfig(req.ip) return res.json(json) } @@ -160,6 +167,18 @@ function customConfig (): CustomConfig { whitelisted: CONFIG.SERVICES.TWITTER.WHITELISTED } }, + client: { + videos: { + miniature: { + preferAuthorDisplayName: CONFIG.CLIENT.VIDEOS.MINIATURE.PREFER_AUTHOR_DISPLAY_NAME + } + }, + menu: { + login: { + redirectOnSingleExternalAuth: CONFIG.CLIENT.MENU.LOGIN.REDIRECT_ON_SINGLE_EXTERNAL_AUTH + } + } + }, cache: { previews: { size: CONFIG.CACHE.PREVIEWS.SIZE @@ -174,7 +193,9 @@ function customConfig (): CustomConfig { signup: { enabled: CONFIG.SIGNUP.ENABLED, limit: CONFIG.SIGNUP.LIMIT, - requiresEmailVerification: CONFIG.SIGNUP.REQUIRES_EMAIL_VERIFICATION + requiresApproval: CONFIG.SIGNUP.REQUIRES_APPROVAL, + requiresEmailVerification: CONFIG.SIGNUP.REQUIRES_EMAIL_VERIFICATION, + minimumAge: CONFIG.SIGNUP.MINIMUM_AGE }, admin: { email: CONFIG.ADMIN.EMAIL @@ -186,6 +207,9 @@ function customConfig (): CustomConfig { videoQuota: CONFIG.USER.VIDEO_QUOTA, videoQuotaDaily: CONFIG.USER.VIDEO_QUOTA_DAILY }, + videoChannels: { + maxPerUser: CONFIG.VIDEO_CHANNELS.MAX_PER_USER + }, transcoding: { enabled: CONFIG.TRANSCODING.ENABLED, allowAdditionalExtensions: CONFIG.TRANSCODING.ALLOW_ADDITIONAL_EXTENSIONS, @@ -195,6 +219,7 @@ function customConfig (): CustomConfig { profile: CONFIG.TRANSCODING.PROFILE, resolutions: { '0p': CONFIG.TRANSCODING.RESOLUTIONS['0p'], + '144p': CONFIG.TRANSCODING.RESOLUTIONS['144p'], '240p': CONFIG.TRANSCODING.RESOLUTIONS['240p'], '360p': CONFIG.TRANSCODING.RESOLUTIONS['360p'], '480p': CONFIG.TRANSCODING.RESOLUTIONS['480p'], @@ -203,6 +228,7 @@ function customConfig (): CustomConfig { '1440p': CONFIG.TRANSCODING.RESOLUTIONS['1440p'], '2160p': CONFIG.TRANSCODING.RESOLUTIONS['2160p'] }, + alwaysTranscodeOriginalResolution: CONFIG.TRANSCODING.ALWAYS_TRANSCODE_ORIGINAL_RESOLUTION, webtorrent: { enabled: CONFIG.TRANSCODING.WEBTORRENT.ENABLED }, @@ -213,6 +239,9 @@ function customConfig (): CustomConfig { live: { enabled: CONFIG.LIVE.ENABLED, allowReplay: CONFIG.LIVE.ALLOW_REPLAY, + latencySetting: { + enabled: CONFIG.LIVE.LATENCY_SETTING.ENABLED + }, maxDuration: CONFIG.LIVE.MAX_DURATION, maxInstanceLives: CONFIG.LIVE.MAX_INSTANCE_LIVES, maxUserLives: CONFIG.LIVE.MAX_USER_LIVES, @@ -221,6 +250,7 @@ function customConfig (): CustomConfig { threads: CONFIG.LIVE.TRANSCODING.THREADS, profile: CONFIG.LIVE.TRANSCODING.PROFILE, resolutions: { + '144p': CONFIG.LIVE.TRANSCODING.RESOLUTIONS['144p'], '240p': CONFIG.LIVE.TRANSCODING.RESOLUTIONS['240p'], '360p': CONFIG.LIVE.TRANSCODING.RESOLUTIONS['360p'], '480p': CONFIG.LIVE.TRANSCODING.RESOLUTIONS['480p'], @@ -228,9 +258,13 @@ function customConfig (): CustomConfig { '1080p': CONFIG.LIVE.TRANSCODING.RESOLUTIONS['1080p'], '1440p': CONFIG.LIVE.TRANSCODING.RESOLUTIONS['1440p'], '2160p': CONFIG.LIVE.TRANSCODING.RESOLUTIONS['2160p'] - } + }, + alwaysTranscodeOriginalResolution: CONFIG.LIVE.TRANSCODING.ALWAYS_TRANSCODE_ORIGINAL_RESOLUTION } }, + videoStudio: { + enabled: CONFIG.VIDEO_STUDIO.ENABLED + }, import: { videos: { concurrency: CONFIG.IMPORT.VIDEOS.CONCURRENCY, @@ -240,6 +274,10 @@ function customConfig (): CustomConfig { torrent: { enabled: CONFIG.IMPORT.VIDEOS.TORRENT.ENABLED } + }, + videoChannelSynchronization: { + enabled: CONFIG.IMPORT.VIDEO_CHANNEL_SYNCHRONIZATION.ENABLED, + maxPerUser: CONFIG.IMPORT.VIDEO_CHANNEL_SYNCHRONIZATION.MAX_PER_USER } }, trending: {