1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 10:19:35 +02:00

WIP plugins: hook on client side

This commit is contained in:
Chocobozzz 2019-07-08 15:54:08 +02:00 committed by Chocobozzz
parent 2c0539420d
commit 18a6f04c07
11 changed files with 215 additions and 3 deletions

View file

@ -75,6 +75,27 @@ export class PluginManager {
return registered
}
getRegisteredPlugins () {
return this.registeredPlugins
}
async runHook (hookName: string, param?: any) {
let result = param
const wait = hookName.startsWith('static:')
for (const hook of this.hooks[hookName]) {
try {
if (wait) result = await hook.handler(param)
else result = hook.handler()
} catch (err) {
logger.error('Cannot run hook %s of plugin %s.', hookName, hook.pluginName, { err })
}
}
return result
}
async unregister (name: string) {
const plugin = this.getRegisteredPlugin(name)