diff options
author | Chocobozzz <me@florianbigard.com> | 2019-07-19 17:30:41 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-07-24 10:58:16 +0200 |
commit | 89cd12756035a146bbcc4db78cd3cd64f2f3d88d (patch) | |
tree | 896cd9fca1e0baa969b1f7a5b398ec1602761661 /server/lib/plugins/plugin-manager.ts | |
parent | 09071200c73f5358e1d0bfb61a274e4f2c4ec52b (diff) | |
download | PeerTube-89cd12756035a146bbcc4db78cd3cd64f2f3d88d.tar.gz PeerTube-89cd12756035a146bbcc4db78cd3cd64f2f3d88d.tar.zst PeerTube-89cd12756035a146bbcc4db78cd3cd64f2f3d88d.zip |
Add hook filters tests
Diffstat (limited to 'server/lib/plugins/plugin-manager.ts')
-rw-r--r-- | server/lib/plugins/plugin-manager.ts | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/server/lib/plugins/plugin-manager.ts b/server/lib/plugins/plugin-manager.ts index 9afda97ea..6485a47c5 100644 --- a/server/lib/plugins/plugin-manager.ts +++ b/server/lib/plugins/plugin-manager.ts | |||
@@ -98,15 +98,15 @@ export class PluginManager implements ServerHook { | |||
98 | 98 | ||
99 | // ###################### Hooks ###################### | 99 | // ###################### Hooks ###################### |
100 | 100 | ||
101 | async runHook (hookName: ServerHookName, param?: any) { | 101 | async runHook <T> (hookName: ServerHookName, result?: T, params?: any): Promise<T> { |
102 | let result = param | 102 | if (!this.hooks[hookName]) return Promise.resolve(result) |
103 | |||
104 | if (!this.hooks[hookName]) return result | ||
105 | 103 | ||
106 | const hookType = getHookType(hookName) | 104 | const hookType = getHookType(hookName) |
107 | 105 | ||
108 | for (const hook of this.hooks[hookName]) { | 106 | for (const hook of this.hooks[hookName]) { |
109 | result = await internalRunHook(hook.handler, hookType, param, err => { | 107 | logger.debug('Running hook %s of plugin %s.', hookName, hook.npmName) |
108 | |||
109 | result = await internalRunHook(hook.handler, hookType, result, params, err => { | ||
110 | logger.error('Cannot run hook %s of plugin %s.', hookName, hook.pluginName, { err }) | 110 | logger.error('Cannot run hook %s of plugin %s.', hookName, hook.pluginName, { err }) |
111 | }) | 111 | }) |
112 | } | 112 | } |