- static setSetting (pluginName: string, pluginType: PluginType, settingName: string, settingValue: string) {
+ static getSettings (
+ pluginName: string,
+ pluginType: PluginType,
+ settingNames: string[],
+ registeredSettings: RegisterServerSettingOptions[]
+ ) {
+ const query = {
+ attributes: [ 'settings' ],
+ where: {
+ name: pluginName,
+ type: pluginType
+ }
+ }
+
+ return PluginModel.findOne(query)
+ .then(p => {
+ const result: SettingEntries = {}
+
+ for (const name of settingNames) {
+ if (!p || !p.settings || p.settings[name] === undefined) {
+ const registered = registeredSettings.find(s => s.name === name)
+
+ if (registered?.default !== undefined) {
+ result[name] = registered.default
+ }
+ } else {
+ result[name] = p.settings[name]
+ }
+ }
+
+ return result
+ })
+ }
+
+ static setSetting (pluginName: string, pluginType: PluginType, settingName: string, settingValue: SettingValue) {