mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-15 18:26:15 +01:00
chore: eslint prefer-template
This commit is contained in:
committed by
Julian Lam
parent
4ee0f1459d
commit
707b55b6a5
@@ -11,13 +11,13 @@ var cache = require('../cache');
|
||||
|
||||
module.exports = function (Categories) {
|
||||
Categories.purge = async function (cid, uid) {
|
||||
await batch.processSortedSet('cid:' + cid + ':tids', async function (tids) {
|
||||
await batch.processSortedSet(`cid:${cid}:tids`, async function (tids) {
|
||||
await async.eachLimit(tids, 10, async function (tid) {
|
||||
await topics.purgePostsAndTopic(tid, uid);
|
||||
});
|
||||
}, { alwaysStartAt: 0 });
|
||||
|
||||
const pinnedTids = await db.getSortedSetRevRange('cid:' + cid + ':tids:pinned', 0, -1);
|
||||
const pinnedTids = await db.getSortedSetRevRange(`cid:${cid}:tids:pinned`, 0, -1);
|
||||
await async.eachLimit(pinnedTids, 10, async function (tid) {
|
||||
await topics.purgePostsAndTopic(tid, uid);
|
||||
});
|
||||
@@ -30,41 +30,41 @@ module.exports = function (Categories) {
|
||||
const cid = categoryData.cid;
|
||||
await db.sortedSetRemoveBulk([
|
||||
['categories:cid', cid],
|
||||
['categories:name', categoryData.name.substr(0, 200).toLowerCase() + ':' + cid],
|
||||
['categories:name', `${categoryData.name.substr(0, 200).toLowerCase()}:${cid}`],
|
||||
]);
|
||||
await removeFromParent(cid);
|
||||
await deleteTags(cid);
|
||||
await db.deleteAll([
|
||||
'cid:' + cid + ':tids',
|
||||
'cid:' + cid + ':tids:pinned',
|
||||
'cid:' + cid + ':tids:posts',
|
||||
'cid:' + cid + ':tids:votes',
|
||||
'cid:' + cid + ':tids:lastposttime',
|
||||
'cid:' + cid + ':recent_tids',
|
||||
'cid:' + cid + ':pids',
|
||||
'cid:' + cid + ':read_by_uid',
|
||||
'cid:' + cid + ':uid:watch:state',
|
||||
'cid:' + cid + ':children',
|
||||
'cid:' + cid + ':tag:whitelist',
|
||||
'category:' + cid,
|
||||
`cid:${cid}:tids`,
|
||||
`cid:${cid}:tids:pinned`,
|
||||
`cid:${cid}:tids:posts`,
|
||||
`cid:${cid}:tids:votes`,
|
||||
`cid:${cid}:tids:lastposttime`,
|
||||
`cid:${cid}:recent_tids`,
|
||||
`cid:${cid}:pids`,
|
||||
`cid:${cid}:read_by_uid`,
|
||||
`cid:${cid}:uid:watch:state`,
|
||||
`cid:${cid}:children`,
|
||||
`cid:${cid}:tag:whitelist`,
|
||||
`category:${cid}`,
|
||||
]);
|
||||
await groups.destroy(privileges.privilegeList.map(privilege => 'cid:' + cid + ':privileges:' + privilege));
|
||||
await groups.destroy(privileges.privilegeList.map(privilege => `cid:${cid}:privileges:${privilege}`));
|
||||
}
|
||||
|
||||
async function removeFromParent(cid) {
|
||||
const [parentCid, children] = await Promise.all([
|
||||
Categories.getCategoryField(cid, 'parentCid'),
|
||||
db.getSortedSetRange('cid:' + cid + ':children', 0, -1),
|
||||
db.getSortedSetRange(`cid:${cid}:children`, 0, -1),
|
||||
]);
|
||||
|
||||
const bulkAdd = [];
|
||||
const childrenKeys = children.map(function (cid) {
|
||||
bulkAdd.push(['cid:0:children', cid, cid]);
|
||||
return 'category:' + cid;
|
||||
return `category:${cid}`;
|
||||
});
|
||||
|
||||
await Promise.all([
|
||||
db.sortedSetRemove('cid:' + parentCid + ':children', cid),
|
||||
db.sortedSetRemove(`cid:${parentCid}:children`, cid),
|
||||
db.setObjectField(childrenKeys, 'parentCid', 0),
|
||||
db.sortedSetAddBulk(bulkAdd),
|
||||
]);
|
||||
@@ -72,17 +72,17 @@ module.exports = function (Categories) {
|
||||
cache.del([
|
||||
'categories:cid',
|
||||
'cid:0:children',
|
||||
'cid:' + parentCid + ':children',
|
||||
'cid:' + parentCid + ':children:all',
|
||||
'cid:' + cid + ':children',
|
||||
'cid:' + cid + ':children:all',
|
||||
'cid:' + cid + ':tag:whitelist',
|
||||
`cid:${parentCid}:children`,
|
||||
`cid:${parentCid}:children:all`,
|
||||
`cid:${cid}:children`,
|
||||
`cid:${cid}:children:all`,
|
||||
`cid:${cid}:tag:whitelist`,
|
||||
]);
|
||||
}
|
||||
|
||||
async function deleteTags(cid) {
|
||||
const tags = await db.getSortedSetMembers('cid:' + cid + ':tags');
|
||||
await db.deleteAll(tags.map(tag => 'cid:' + cid + ':tag:' + tag + ':topics'));
|
||||
await db.delete('cid:' + cid + ':tags');
|
||||
const tags = await db.getSortedSetMembers(`cid:${cid}:tags`);
|
||||
await db.deleteAll(tags.map(tag => `cid:${cid}:tag:${tag}:topics`));
|
||||
await db.delete(`cid:${cid}:tags`);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user