mirror of https://github.com/Chocobozzz/PeerTube
Handle hook with Promise as result
parent
b1d8261c45
commit
2e5dd0bef8
|
@ -105,11 +105,16 @@ class PluginsManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async runHook<T> (hookName: ClientHookName, result?: T, params?: any) {
|
async runHook<T> (hookName: ClientHookName, resultArg?: T | Promise<T>, params?: any) {
|
||||||
if (!this.hooks[hookName]) return result
|
if (!this.hooks[hookName]) {
|
||||||
|
// eslint-disable-next-line no-return-await
|
||||||
|
return await resultArg
|
||||||
|
}
|
||||||
|
|
||||||
const hookType = getHookType(hookName)
|
const hookType = getHookType(hookName)
|
||||||
|
|
||||||
|
let result = await resultArg
|
||||||
|
|
||||||
for (const hook of this.hooks[hookName]) {
|
for (const hook of this.hooks[hookName]) {
|
||||||
logger.info(`Running hook ${hookName} of plugin ${hook.plugin.name}`)
|
logger.info(`Running hook ${hookName} of plugin ${hook.plugin.name}`)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue