aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/plugins
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-07-12 14:06:33 +0200
committerChocobozzz <chocobozzz@cpy.re>2019-07-24 10:58:16 +0200
commitb2195fafc292d6761c25fe51ca4e0328ab403424 (patch)
tree3c390aeb5c5b9648668961871e866bd5e1dde5a4 /server/lib/plugins
parentb5f919ac8eb2a1c20e26582fdfd377d687710d8f (diff)
downloadPeerTube-b2195fafc292d6761c25fe51ca4e0328ab403424.tar.gz
PeerTube-b2195fafc292d6761c25fe51ca4e0328ab403424.tar.zst
PeerTube-b2195fafc292d6761c25fe51ca4e0328ab403424.zip
WIP plugins: add storage manager
Diffstat (limited to 'server/lib/plugins')
-rw-r--r--server/lib/plugins/plugin-manager.ts14
1 files changed, 13 insertions, 1 deletions
diff --git a/server/lib/plugins/plugin-manager.ts b/server/lib/plugins/plugin-manager.ts
index 2fa80e878..7576b284c 100644
--- a/server/lib/plugins/plugin-manager.ts
+++ b/server/lib/plugins/plugin-manager.ts
@@ -13,6 +13,7 @@ import { outputFile } from 'fs-extra'
13import { RegisterSettingOptions } from '../../../shared/models/plugins/register-setting.model' 13import { RegisterSettingOptions } from '../../../shared/models/plugins/register-setting.model'
14import { RegisterHookOptions } from '../../../shared/models/plugins/register-hook.model' 14import { RegisterHookOptions } from '../../../shared/models/plugins/register-hook.model'
15import { PluginSettingsManager } from '../../../shared/models/plugins/plugin-settings-manager.model' 15import { PluginSettingsManager } from '../../../shared/models/plugins/plugin-settings-manager.model'
16import { PluginStorageManager } from '../../../shared/models/plugins/plugin-storage-manager.model'
16 17
17export interface RegisteredPlugin { 18export interface RegisteredPlugin {
18 npmName: string 19 npmName: string
@@ -307,13 +308,24 @@ export class PluginManager {
307 setSetting: (name: string, value: string) => PluginModel.setSetting(plugin.name, plugin.type, name, value) 308 setSetting: (name: string, value: string) => PluginModel.setSetting(plugin.name, plugin.type, name, value)
308 } 309 }
309 310
311 const storageManager: PluginStorageManager = {
312 getData: (key: string) => PluginModel.getData(plugin.name, plugin.type, key),
313
314 storeData: (key: string, data: any) => PluginModel.storeData(plugin.name, plugin.type, key, data)
315 }
316
310 const library: PluginLibrary = require(join(pluginPath, packageJSON.library)) 317 const library: PluginLibrary = require(join(pluginPath, packageJSON.library))
311 318
312 if (!isLibraryCodeValid(library)) { 319 if (!isLibraryCodeValid(library)) {
313 throw new Error('Library code is not valid (miss register or unregister function)') 320 throw new Error('Library code is not valid (miss register or unregister function)')
314 } 321 }
315 322
316 library.register({ registerHook, registerSetting, settingsManager }) 323 library.register({
324 registerHook,
325 registerSetting,
326 settingsManager,
327 storageManager
328 })
317 329
318 logger.info('Add plugin %s CSS to global file.', npmName) 330 logger.info('Add plugin %s CSS to global file.', npmName)
319 331