]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/api/config.ts
Add notifications in the client
[github/Chocobozzz/PeerTube.git] / server / controllers / api / config.ts
index 633cf5e34ef7beff34d519a70ac55b095cc6d2d9..c75002aafee8abb35b2eced175eb458af3b4e490 100644 (file)
@@ -10,7 +10,8 @@ import { customConfigUpdateValidator } from '../../middlewares/validators/config
 import { ClientHtml } from '../../lib/client-html'
 import { auditLoggerFactory, CustomConfigAuditView, getAuditIdFromRes } from '../../helpers/audit-logger'
 import { remove, writeJSON } from 'fs-extra'
-import { version } from '../../tools/cli'
+import { getServerCommit } from '../../helpers/utils'
+import { Emailer } from '../../lib/emailer'
 
 const packageJSON = require('../../../../package.json')
 const configRouter = express.Router()
@@ -40,11 +41,11 @@ configRouter.delete('/custom',
 )
 
 let serverCommit: string
-async function getConfig (req: express.Request, res: express.Response, next: express.NextFunction) {
+async function getConfig (req: express.Request, res: express.Response) {
   const allowed = await isSignupAllowed()
   const allowedForCurrentIP = isSignupAllowedForCurrentIP(req.ip)
-  serverCommit = (serverCommit) ? serverCommit : version()
-  if (serverCommit === packageJSON.version) serverCommit = ''
+
+  if (serverCommit === undefined) serverCommit = await getServerCommit()
 
   const enabledResolutions = Object.keys(CONFIG.TRANSCODING.RESOLUTIONS)
    .filter(key => CONFIG.TRANSCODING.ENABLED === CONFIG.TRANSCODING.RESOLUTIONS[key] === true)
@@ -61,6 +62,9 @@ async function getConfig (req: express.Request, res: express.Response, next: exp
         css: CONFIG.INSTANCE.CUSTOMIZATIONS.CSS
       }
     },
+    email: {
+      enabled: Emailer.Instance.isEnabled()
+    },
     serverVersion: packageJSON.version,
     serverCommit,
     signup: {
@@ -168,7 +172,8 @@ async function updateCustomConfig (req: express.Request, res: express.Response,
     'instance.defaultClientRoute',
     'instance.shortDescription',
     'cache.videoCaptions',
-    'signup.requiresEmailVerification'
+    'signup.requiresEmailVerification',
+    'transcoding.allowAdditionalExtensions'
   )
   toUpdateJSON.user['video_quota'] = toUpdate.user.videoQuota
   toUpdateJSON.user['video_quota_daily'] = toUpdate.user.videoQuotaDaily
@@ -176,6 +181,7 @@ async function updateCustomConfig (req: express.Request, res: express.Response,
   toUpdateJSON.instance['short_description'] = toUpdate.instance.shortDescription
   toUpdateJSON.instance['default_nsfw_policy'] = toUpdate.instance.defaultNSFWPolicy
   toUpdateJSON.signup['requires_email_verification'] = toUpdate.signup.requiresEmailVerification
+  toUpdateJSON.transcoding['allow_additional_extensions'] = toUpdate.transcoding.allowAdditionalExtensions
 
   await writeJSON(CONFIG.CUSTOM_FILE, toUpdateJSON, { spaces: 2 })
 
@@ -243,6 +249,7 @@ function customConfig (): CustomConfig {
     },
     transcoding: {
       enabled: CONFIG.TRANSCODING.ENABLED,
+      allowAdditionalExtensions: CONFIG.TRANSCODING.ALLOW_ADDITIONAL_EXTENSIONS,
       threads: CONFIG.TRANSCODING.THREADS,
       resolutions: {
         '240p': CONFIG.TRANSCODING.RESOLUTIONS[ '240p' ],