put appstore whitelist/blacklist in db

This commit is contained in:
Girish Ramakrishnan
2020-02-05 11:58:10 -08:00
parent 25ef5ab636
commit 2f6933102c
3 changed files with 56 additions and 11 deletions

View File

@@ -49,6 +49,8 @@ exports = module.exports = {
getFooter: getFooter,
setFooter: setFooter,
getAppstoreListingConfig: getAppstoreListingConfig,
provider: provider,
getAll: getAll,
@@ -78,6 +80,7 @@ exports = module.exports = {
EXTERNAL_LDAP_KEY: 'external_ldap_config',
REGISTRY_CONFIG_KEY: 'registry_config',
SYSINFO_CONFIG_KEY: 'sysinfo_config',
APPSTORE_LISTING_CONFIG_KEY: 'appstore_listing_config',
// strings
APP_AUTOUPDATE_PATTERN_KEY: 'app_autoupdate_pattern',
@@ -155,6 +158,11 @@ let gDefaults = (function () {
result[exports.WEB_SERVER_ORIGIN_KEY] = 'https://cloudron.io';
result[exports.DEMO_KEY] = false;
result[exports.APPSTORE_LISTING_CONFIG_KEY] = {
blacklist: [],
whitelist: null // null imples, not set. this is an object and not an array
};
result[exports.FOOTER_KEY] = '&copy; 2020 [Cloudron](https://cloudron.io) [Forum <i class="fa fa-comments"></i>](https://forum.cloudron.io)';
return result;
@@ -520,6 +528,17 @@ function setSysinfoConfig(sysinfoConfig, callback) {
});
}
function getAppstoreListingConfig(callback) {
assert.strictEqual(typeof callback, 'function');
settingsdb.get(exports.APPSTORE_LISTING_CONFIG_KEY, function (error, value) {
if (error && error.reason === BoxError.NOT_FOUND) return callback(null, gDefaults[exports.APPSTORE_LISTING_CONFIG_KEY]);
if (error) return callback(error);
callback(null, JSON.parse(value));
});
}
function getLicenseKey(callback) {
assert.strictEqual(typeof callback, 'function');