diff options
author | Chocobozzz <me@florianbigard.com> | 2019-07-12 14:06:33 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-07-24 10:58:16 +0200 |
commit | b2195fafc292d6761c25fe51ca4e0328ab403424 (patch) | |
tree | 3c390aeb5c5b9648668961871e866bd5e1dde5a4 /server/lib/plugins/plugin-manager.ts | |
parent | b5f919ac8eb2a1c20e26582fdfd377d687710d8f (diff) | |
download | PeerTube-b2195fafc292d6761c25fe51ca4e0328ab403424.tar.gz PeerTube-b2195fafc292d6761c25fe51ca4e0328ab403424.tar.zst PeerTube-b2195fafc292d6761c25fe51ca4e0328ab403424.zip |
WIP plugins: add storage manager
Diffstat (limited to 'server/lib/plugins/plugin-manager.ts')
-rw-r--r-- | server/lib/plugins/plugin-manager.ts | 14 |
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' | |||
13 | import { RegisterSettingOptions } from '../../../shared/models/plugins/register-setting.model' | 13 | import { RegisterSettingOptions } from '../../../shared/models/plugins/register-setting.model' |
14 | import { RegisterHookOptions } from '../../../shared/models/plugins/register-hook.model' | 14 | import { RegisterHookOptions } from '../../../shared/models/plugins/register-hook.model' |
15 | import { PluginSettingsManager } from '../../../shared/models/plugins/plugin-settings-manager.model' | 15 | import { PluginSettingsManager } from '../../../shared/models/plugins/plugin-settings-manager.model' |
16 | import { PluginStorageManager } from '../../../shared/models/plugins/plugin-storage-manager.model' | ||
16 | 17 | ||
17 | export interface RegisteredPlugin { | 18 | export 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 | ||