aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/initializers/constants.ts2
-rw-r--r--server/lib/plugins/plugin-manager.ts12
-rw-r--r--server/models/server/plugin.ts9
3 files changed, 17 insertions, 6 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index 93ccb7da8..1111fd97f 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -19,7 +19,7 @@ const LAST_MIGRATION_VERSION = 400
19// --------------------------------------------------------------------------- 19// ---------------------------------------------------------------------------
20 20
21const API_VERSION = 'v1' 21const API_VERSION = 'v1'
22const PEERTUBE_VERSION = process.env.npm_package_version || 'unknown' 22const PEERTUBE_VERSION = require(join(root(), 'package.json')).version
23 23
24const PAGINATION = { 24const PAGINATION = {
25 COUNT: { 25 COUNT: {
diff --git a/server/lib/plugins/plugin-manager.ts b/server/lib/plugins/plugin-manager.ts
index 9e4ec5adf..570b56193 100644
--- a/server/lib/plugins/plugin-manager.ts
+++ b/server/lib/plugins/plugin-manager.ts
@@ -104,10 +104,12 @@ export class PluginManager {
104 104
105 for (const hook of this.hooks[hookName]) { 105 for (const hook of this.hooks[hookName]) {
106 try { 106 try {
107 const p = hook.handler(param)
108
107 if (wait) { 109 if (wait) {
108 result = await hook.handler(param) 110 result = await p
109 } else { 111 } else if (p.catch) {
110 result = hook.handler() 112 p.catch(err => logger.warn('Hook %s of plugin %s thrown an error.', hookName, hook.pluginName, { err }))
111 } 113 }
112 } catch (err) { 114 } catch (err) {
113 logger.error('Cannot run hook %s of plugin %s.', hookName, hook.pluginName, { err }) 115 logger.error('Cannot run hook %s of plugin %s.', hookName, hook.pluginName, { err })
@@ -329,7 +331,7 @@ export class PluginManager {
329 registerSetting, 331 registerSetting,
330 settingsManager, 332 settingsManager,
331 storageManager 333 storageManager
332 }) 334 }).catch(err => logger.error('Cannot register plugin %s.', npmName, { err }))
333 335
334 logger.info('Add plugin %s CSS to global file.', npmName) 336 logger.info('Add plugin %s CSS to global file.', npmName)
335 337
@@ -365,7 +367,7 @@ export class PluginManager {
365 private async regeneratePluginGlobalCSS () { 367 private async regeneratePluginGlobalCSS () {
366 await this.resetCSSGlobalFile() 368 await this.resetCSSGlobalFile()
367 369
368 for (const key of Object.keys(this.registeredPlugins)) { 370 for (const key of Object.keys(this.getRegisteredPlugins())) {
369 const plugin = this.registeredPlugins[key] 371 const plugin = this.registeredPlugins[key]
370 372
371 await this.addCSSToGlobalFile(plugin.path, plugin.css) 373 await this.addCSSToGlobalFile(plugin.path, plugin.css)
diff --git a/server/models/server/plugin.ts b/server/models/server/plugin.ts
index 50963ba57..f39b97ef0 100644
--- a/server/models/server/plugin.ts
+++ b/server/models/server/plugin.ts
@@ -156,6 +156,15 @@ export class PluginModel extends Model<PluginModel> {
156 return PluginModel.findOne(query) 156 return PluginModel.findOne(query)
157 .then((c: any) => { 157 .then((c: any) => {
158 if (!c) return undefined 158 if (!c) return undefined
159 const value = c.value
160
161 if (typeof value === 'string' && value.startsWith('{')) {
162 try {
163 return JSON.parse(value)
164 } catch {
165 return value
166 }
167 }
159 168
160 return c.value 169 return c.value
161 }) 170 })