diff options
Diffstat (limited to 'server/models')
-rw-r--r-- | server/models/server/plugin.ts | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/server/models/server/plugin.ts b/server/models/server/plugin.ts index 95774a467..83c873c5b 100644 --- a/server/models/server/plugin.ts +++ b/server/models/server/plugin.ts | |||
@@ -129,6 +129,31 @@ export class PluginModel extends Model<PluginModel> { | |||
129 | }) | 129 | }) |
130 | } | 130 | } |
131 | 131 | ||
132 | static getSettings (pluginName: string, pluginType: PluginType, settingNames: string[]) { | ||
133 | const query = { | ||
134 | attributes: [ 'settings' ], | ||
135 | where: { | ||
136 | name: pluginName, | ||
137 | type: pluginType | ||
138 | } | ||
139 | } | ||
140 | |||
141 | return PluginModel.findOne(query) | ||
142 | .then(p => { | ||
143 | if (!p || !p.settings) return {} | ||
144 | |||
145 | const result: { [settingName: string ]: string } = {} | ||
146 | |||
147 | for (const key of Object.keys(p.settings)) { | ||
148 | if (settingNames.includes(key)) { | ||
149 | result[key] = p.settings[key] | ||
150 | } | ||
151 | } | ||
152 | |||
153 | return result | ||
154 | }) | ||
155 | } | ||
156 | |||
132 | static setSetting (pluginName: string, pluginType: PluginType, settingName: string, settingValue: string) { | 157 | static setSetting (pluginName: string, pluginType: PluginType, settingName: string, settingValue: string) { |
133 | const query = { | 158 | const query = { |
134 | where: { | 159 | where: { |