]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Add ability for plugins to add metadata
authorChocobozzz <me@florianbigard.com>
Fri, 10 Mar 2023 10:10:16 +0000 (11:10 +0100)
committerChocobozzz <me@florianbigard.com>
Tue, 14 Mar 2023 13:17:58 +0000 (14:17 +0100)
client/src/app/core/plugins/hooks.service.ts

index d9fef838978dd874ba8b246d4166da0772946351..978316ec2a943407921fc435d20170b8504268f6 100644 (file)
@@ -48,6 +48,15 @@ export class HooksService {
     return this.pluginService.runHook(hookResultName, result, params)
   }
 
+  async wrapFunResult <P, R, H extends ClientFilterHookName>
+  (fun: RawFunction<P, R>, params: P, scope: PluginClientScope, hookResultName: H) {
+    await this.pluginService.ensurePluginsAreLoaded(scope)
+
+    const result = fun(params)
+
+    return this.pluginService.runHook(hookResultName, result, params)
+  }
+
   runAction<T, U extends ClientActionHookName> (hookName: U, scope: PluginClientScope, params?: T) {
     // Use setTimeout to give priority to Angular change detector
     setTimeout(() => {