aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/plugins
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-07-08 15:54:08 +0200
committerChocobozzz <chocobozzz@cpy.re>2019-07-24 10:58:16 +0200
commit18a6f04c071f7a0735eb39b8c67fd51a082d1a31 (patch)
treeb9fb0637878390d32b5c73d02b8eee2ef48cbfa5 /server/lib/plugins
parent2c0539420d77339e6afe8d7920b44af4c0dcb1e6 (diff)
downloadPeerTube-18a6f04c071f7a0735eb39b8c67fd51a082d1a31.tar.gz
PeerTube-18a6f04c071f7a0735eb39b8c67fd51a082d1a31.tar.zst
PeerTube-18a6f04c071f7a0735eb39b8c67fd51a082d1a31.zip
WIP plugins: hook on client side
Diffstat (limited to 'server/lib/plugins')
-rw-r--r--server/lib/plugins/plugin-manager.ts21
1 files changed, 21 insertions, 0 deletions
diff --git a/server/lib/plugins/plugin-manager.ts b/server/lib/plugins/plugin-manager.ts
index b898e64fa..7cbfa8569 100644
--- a/server/lib/plugins/plugin-manager.ts
+++ b/server/lib/plugins/plugin-manager.ts
@@ -75,6 +75,27 @@ export class PluginManager {
75 return registered 75 return registered
76 } 76 }
77 77
78 getRegisteredPlugins () {
79 return this.registeredPlugins
80 }
81
82 async runHook (hookName: string, param?: any) {
83 let result = param
84
85 const wait = hookName.startsWith('static:')
86
87 for (const hook of this.hooks[hookName]) {
88 try {
89 if (wait) result = await hook.handler(param)
90 else result = hook.handler()
91 } catch (err) {
92 logger.error('Cannot run hook %s of plugin %s.', hookName, hook.pluginName, { err })
93 }
94 }
95
96 return result
97 }
98
78 async unregister (name: string) { 99 async unregister (name: string) {
79 const plugin = this.getRegisteredPlugin(name) 100 const plugin = this.getRegisteredPlugin(name)
80 101