2020-07-29 12:50:18 -04:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
const SocketCache = module.exports;
|
|
|
|
|
|
2021-09-24 19:58:10 -04:00
|
|
|
const db = require('../../database');
|
|
|
|
|
|
2020-11-07 22:06:25 -05:00
|
|
|
SocketCache.clear = async function (socket, data) {
|
|
|
|
|
if (data.name === 'post') {
|
|
|
|
|
require('../../posts/cache').reset();
|
2021-09-24 19:58:10 -04:00
|
|
|
} else if (data.name === 'object' && db.objectCache) {
|
|
|
|
|
db.objectCache.reset();
|
2020-11-07 22:06:25 -05:00
|
|
|
} else if (data.name === 'group') {
|
|
|
|
|
require('../../groups').cache.reset();
|
|
|
|
|
} else if (data.name === 'local') {
|
|
|
|
|
require('../../cache').reset();
|
|
|
|
|
}
|
2020-07-29 12:50:18 -04:00
|
|
|
};
|
2020-11-06 23:13:12 -05:00
|
|
|
|
|
|
|
|
SocketCache.toggle = async function (socket, data) {
|
|
|
|
|
const caches = {
|
|
|
|
|
post: require('../../posts/cache'),
|
2021-09-24 19:58:10 -04:00
|
|
|
object: db.objectCache,
|
2020-11-06 23:13:12 -05:00
|
|
|
group: require('../../groups').cache,
|
|
|
|
|
local: require('../../cache'),
|
|
|
|
|
};
|
|
|
|
|
if (!caches[data.name]) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
caches[data.name].enabled = data.enabled;
|
|
|
|
|
};
|