1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-03 17:59:37 +02:00

Add hook filters tests

This commit is contained in:
Chocobozzz 2019-07-19 17:30:41 +02:00 committed by Chocobozzz
parent 09071200c7
commit 89cd127560
18 changed files with 306 additions and 80 deletions

View file

@ -98,15 +98,15 @@ export class PluginManager implements ServerHook {
// ###################### Hooks ######################
async runHook (hookName: ServerHookName, param?: any) {
let result = param
if (!this.hooks[hookName]) return result
async runHook <T> (hookName: ServerHookName, result?: T, params?: any): Promise<T> {
if (!this.hooks[hookName]) return Promise.resolve(result)
const hookType = getHookType(hookName)
for (const hook of this.hooks[hookName]) {
result = await internalRunHook(hook.handler, hookType, param, err => {
logger.debug('Running hook %s of plugin %s.', hookName, hook.npmName)
result = await internalRunHook(hook.handler, hookType, result, params, err => {
logger.error('Cannot run hook %s of plugin %s.', hookName, hook.pluginName, { err })
})
}