Move ghosts into settings table

This commit is contained in:
Johannes Zellner
2021-09-20 13:05:42 +02:00
parent f66af19458
commit c6c62de68a
2 changed files with 43 additions and 11 deletions

View File

@@ -59,6 +59,9 @@ exports = module.exports = {
getFirewallBlocklist,
setFirewallBlocklist,
getGhosts,
setGhosts,
getSupportConfig,
provider,
list,
@@ -93,6 +96,7 @@ exports = module.exports = {
APPSTORE_LISTING_CONFIG_KEY: 'appstore_listing_config',
SUPPORT_CONFIG_KEY: 'support_config',
DIRECTORY_CONFIG_KEY: 'directory_config',
GHOSTS_CONFIG_KEY: 'ghosts_config',
// strings
AUTOUPDATE_PATTERN_KEY: 'autoupdate_pattern',
@@ -197,6 +201,8 @@ const gDefaults = (function () {
whitelist: null // null imples nothing is whitelisted. this is an array
};
result[exports.GHOSTS_CONFIG_KEY] = {};
result[exports.SUPPORT_CONFIG_KEY] = {
email: 'support@cloudron.io',
remoteSupport: true,
@@ -579,6 +585,20 @@ async function setFirewallBlocklist(blocklist) {
await setBlob(exports.FIREWALL_BLOCKLIST_KEY, Buffer.from(blocklist));
}
async function getGhosts() {
const value = await get(exports.GHOSTS_CONFIG_KEY);
if (value === null) return gDefaults[exports.GHOSTS_CONFIG_KEY];
return JSON.parse(value);
}
async function setGhosts(ghosts) {
assert.strictEqual(typeof ghosts, 'object');
await set(exports.GHOSTS_CONFIG_KEY, JSON.stringify(ghosts));
notifyChange(exports.GHOSTS_CONFIG_KEY, ghosts);
}
async function getSupportConfig() {
const value = await get(exports.SUPPORT_CONFIG_KEY);
if (value === null) return gDefaults[exports.SUPPORT_CONFIG_KEY];