|
|
@ -4,10 +4,15 @@ const db = require('../database');
|
|
|
|
const plugins = require('../plugins');
|
|
|
|
const plugins = require('../plugins');
|
|
|
|
const Meta = require('./index');
|
|
|
|
const Meta = require('./index');
|
|
|
|
const pubsub = require('../pubsub');
|
|
|
|
const pubsub = require('../pubsub');
|
|
|
|
|
|
|
|
const cache = require('../cache');
|
|
|
|
|
|
|
|
|
|
|
|
const Settings = module.exports;
|
|
|
|
const Settings = module.exports;
|
|
|
|
|
|
|
|
|
|
|
|
Settings.get = async function (hash) {
|
|
|
|
Settings.get = async function (hash) {
|
|
|
|
|
|
|
|
const cached = cache.get('settings:' + hash);
|
|
|
|
|
|
|
|
if (cached) {
|
|
|
|
|
|
|
|
return cached;
|
|
|
|
|
|
|
|
}
|
|
|
|
let data = await db.getObject('settings:' + hash) || {};
|
|
|
|
let data = await db.getObject('settings:' + hash) || {};
|
|
|
|
const sortedLists = await db.getSetMembers('settings:' + hash + ':sorted-lists');
|
|
|
|
const sortedLists = await db.getSetMembers('settings:' + hash + ':sorted-lists');
|
|
|
|
|
|
|
|
|
|
|
@ -27,6 +32,7 @@ Settings.get = async function (hash) {
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
({ values: data } = await plugins.fireHook('filter:settings.get', { plugin: hash, values: data }));
|
|
|
|
({ values: data } = await plugins.fireHook('filter:settings.get', { plugin: hash, values: data }));
|
|
|
|
|
|
|
|
cache.set('settings:' + hash, data);
|
|
|
|
return data;
|
|
|
|
return data;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -86,6 +92,7 @@ Settings.set = async function (hash, values, quiet) {
|
|
|
|
|
|
|
|
|
|
|
|
pubsub.publish('action:settings.set.' + hash, values);
|
|
|
|
pubsub.publish('action:settings.set.' + hash, values);
|
|
|
|
Meta.reloadRequired = !quiet;
|
|
|
|
Meta.reloadRequired = !quiet;
|
|
|
|
|
|
|
|
cache.del('settings:' + hash);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Settings.setOne = async function (hash, field, value) {
|
|
|
|
Settings.setOne = async function (hash, field, value) {
|
|
|
|