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:
parent
2c0539420d
commit
18a6f04c07
11 changed files with 215 additions and 3 deletions
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue