fix: remove unused crypto unit fields

This commit is contained in:
Sérgio Salgado 2022-07-27 19:36:59 +01:00
parent 3b01820242
commit 65b8491354
4 changed files with 38 additions and 11 deletions

View file

@ -85,6 +85,17 @@ function saveConfig (config) {
})
}
function removeFromConfig (fields) {
return Promise.all([loadLatestConfigOrNone(), getOperatorId('middleware')])
.then(([currentConfig, operatorId]) => {
const newConfig = _.omit(fields, currentConfig)
return db.tx(t => {
return t.none(configSql, ['config', { config: newConfig }, true, NEW_SETTINGS_LOADER_SCHEMA_VERSION])
.then(() => t.none('NOTIFY $1:name, $2', ['reload', JSON.stringify({ schema: asyncLocalStorage.getStore().get('schema'), operatorId })]))
}).catch(console.error)
})
}
function migrationSaveConfig (config) {
return loadLatestConfigOrNone()
.then(currentConfig => {
@ -194,5 +205,6 @@ module.exports = {
loadLatestConfig,
loadLatestConfigOrNone,
load,
migrate
migrate,
removeFromConfig
}