]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/plugins/plugin-manager.ts
Logging ip requesting unknown infoHash
[github/Chocobozzz/PeerTube.git] / server / lib / plugins / plugin-manager.ts
index f7b84b1ff1b7013d5e89651e5107bc69ba8f059d..950acf7ad75a3cca34c120cecfd5a0369caf0dcd 100644 (file)
@@ -144,20 +144,6 @@ export class PluginManager implements ServerHook {
     return this.translations[locale] || {}
   }
 
-  onLogout (npmName: string, authName: string, user: MUser) {
-    const auth = this.getAuth(npmName, authName)
-
-    if (auth?.onLogout) {
-      logger.info('Running onLogout function from auth %s of plugin %s', authName, npmName)
-
-      try {
-        auth.onLogout(user)
-      } catch (err) {
-        logger.warn('Cannot run onLogout function from auth %s of plugin %s.', authName, npmName, { err })
-      }
-    }
-  }
-
   async isTokenValid (token: MOAuthTokenUser, type: 'access' | 'refresh') {
     const auth = this.getAuth(token.User.pluginAuth, token.authName)
     if (!auth) return true
@@ -180,6 +166,37 @@ export class PluginManager implements ServerHook {
     return true
   }
 
+  // ###################### External events ######################
+
+  onLogout (npmName: string, authName: string, user: MUser) {
+    const auth = this.getAuth(npmName, authName)
+
+    if (auth?.onLogout) {
+      logger.info('Running onLogout function from auth %s of plugin %s', authName, npmName)
+
+      try {
+        auth.onLogout(user)
+      } catch (err) {
+        logger.warn('Cannot run onLogout function from auth %s of plugin %s.', authName, npmName, { err })
+      }
+    }
+  }
+
+  onSettingsChanged (name: string, settings: any) {
+    const registered = this.getRegisteredPluginByShortName(name)
+    if (!registered) {
+      logger.error('Cannot find plugin %s to call on settings changed.', name)
+    }
+
+    for (const cb of registered.registerHelpersStore.getOnSettingsChangedCallbacks()) {
+      try {
+        cb(settings)
+      } catch (err) {
+        logger.error('Cannot run on settings changed callback for %s.', registered.npmName, { err })
+      }
+    }
+  }
+
   // ###################### Hooks ######################
 
   async runHook<T> (hookName: ServerHookName, result?: T, params?: any): Promise<T> {