]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/server/plugin.ts
Add getSettings documentation
[github/Chocobozzz/PeerTube.git] / server / models / server / plugin.ts
index 95774a4674634bf8609cedc5bdd5ff619054180e..83c873c5bad8dabc86c476e0c868a87f835e874e 100644 (file)
@@ -129,6 +129,31 @@ export class PluginModel extends Model<PluginModel> {
       })
   }
 
+  static getSettings (pluginName: string, pluginType: PluginType, settingNames: string[]) {
+    const query = {
+      attributes: [ 'settings' ],
+      where: {
+        name: pluginName,
+        type: pluginType
+      }
+    }
+
+    return PluginModel.findOne(query)
+      .then(p => {
+        if (!p || !p.settings) return {}
+
+        const result: { [settingName: string ]: string } = {}
+
+        for (const key of Object.keys(p.settings)) {
+          if (settingNames.includes(key)) {
+            result[key] = p.settings[key]
+          }
+        }
+
+        return result
+      })
+  }
+
   static setSetting (pluginName: string, pluginType: PluginType, settingName: string, settingValue: string) {
     const query = {
       where: {