diff options
author | Chocobozzz <me@florianbigard.com> | 2020-04-27 10:19:14 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-05-04 16:21:39 +0200 |
commit | 055cfb11a9d688dbc2dce5c164d1f0b311918378 (patch) | |
tree | c93f008b3e5463a9b8d024b45e5ba4b9f549a76b /server/models | |
parent | e307e4fce39853d445d086f92b8c556c363ee15d (diff) | |
download | PeerTube-055cfb11a9d688dbc2dce5c164d1f0b311918378.tar.gz PeerTube-055cfb11a9d688dbc2dce5c164d1f0b311918378.tar.zst PeerTube-055cfb11a9d688dbc2dce5c164d1f0b311918378.zip |
Add plugin auth migrations
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: { |