reload plugin when its settings change, fix #262

This commit is contained in:
lesion 2023-05-01 21:20:32 +02:00
parent 3468c34b28
commit 93616af565
No known key found for this signature in database
GPG key ID: 352918250B012177
2 changed files with 14 additions and 1 deletions

@ -1 +1 @@
Subproject commit 12640461481cc39cdee8efa05e7fd02a6a60e99c
Subproject commit c1237728ad0101cc9cab4de3417d323f56abff70

View file

@ -126,6 +126,19 @@ const settingsController = {
async setRequest (req, res) {
const { key, value, is_secret } = req.body
const ret = await settingsController.set(key, value, is_secret)
// reload plugin when its settings change
if (key.startsWith('plugin_')) {
const pluginName = key.slice(7)
try {
const pluginController = require('./plugins')
pluginController.unloadPlugin(pluginName)
pluginController.loadPlugin(pluginName)
} catch (e) {
log.error(e)
}
}
if (ret) { res.sendStatus(200) } else { res.sendStatus(400) }
},