aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib')
-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