mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-14 10:37:45 +01:00
refactor: add guards against bad data & infi loops
This commit is contained in:
@@ -17,12 +17,14 @@ module.exports = function (Categories) {
|
|||||||
await async.eachLimit(tids, 10, async (tid) => {
|
await async.eachLimit(tids, 10, async (tid) => {
|
||||||
await topics.purgePostsAndTopic(tid, uid);
|
await topics.purgePostsAndTopic(tid, uid);
|
||||||
});
|
});
|
||||||
|
await db.sortedSetRemove(`cid:${cid}:tids`, tids);
|
||||||
}, { alwaysStartAt: 0 });
|
}, { 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 (tid) => {
|
await async.eachLimit(pinnedTids, 10, async (tid) => {
|
||||||
await topics.purgePostsAndTopic(tid, uid);
|
await topics.purgePostsAndTopic(tid, uid);
|
||||||
});
|
});
|
||||||
|
await db.sortedSetRemove(`cid:${cid}:tids:pinned`, pinnedTids);
|
||||||
const categoryData = await Categories.getCategoryData(cid);
|
const categoryData = await Categories.getCategoryData(cid);
|
||||||
await purgeCategory(cid, categoryData);
|
await purgeCategory(cid, categoryData);
|
||||||
plugins.hooks.fire('action:category.delete', { cid: cid, uid: uid, category: categoryData });
|
plugins.hooks.fire('action:category.delete', { cid: cid, uid: uid, category: categoryData });
|
||||||
|
|||||||
@@ -261,6 +261,7 @@ events.deleteEvents = async function (eids) {
|
|||||||
events.deleteAll = async function () {
|
events.deleteAll = async function () {
|
||||||
await batch.processSortedSet('events:time', async (eids) => {
|
await batch.processSortedSet('events:time', async (eids) => {
|
||||||
await events.deleteEvents(eids);
|
await events.deleteEvents(eids);
|
||||||
|
await db.sortedSetRemove('events:time', eids);
|
||||||
}, { alwaysStartAt: 0, batch: 500 });
|
}, { alwaysStartAt: 0, batch: 500 });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -43,15 +43,17 @@ module.exports = function (User) {
|
|||||||
async function deletePosts(callerUid, uid) {
|
async function deletePosts(callerUid, uid) {
|
||||||
await batch.processSortedSet(`uid:${uid}:posts`, async (pids) => {
|
await batch.processSortedSet(`uid:${uid}:posts`, async (pids) => {
|
||||||
await posts.purge(pids, callerUid);
|
await posts.purge(pids, callerUid);
|
||||||
|
await db.sortedSetRemove(`uid:${uid}:posts`, pids);
|
||||||
}, { alwaysStartAt: 0, batch: 500 });
|
}, { alwaysStartAt: 0, batch: 500 });
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteTopics(callerUid, uid) {
|
async function deleteTopics(callerUid, uid) {
|
||||||
await batch.processSortedSet(`uid:${uid}:topics`, async (ids) => {
|
await batch.processSortedSet(`uid:${uid}:topics`, async (tids) => {
|
||||||
await async.eachSeries(ids, async (tid) => {
|
await async.eachSeries(tids, async (tid) => {
|
||||||
await topics.purge(tid, callerUid);
|
await topics.purge(tid, callerUid);
|
||||||
});
|
});
|
||||||
}, { alwaysStartAt: 0 });
|
await db.sortedSetRemove(`uid:${uid}:topics`, tids);
|
||||||
|
}, { alwaysStartAt: 0, batch: 100 });
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteUploads(callerUid, uid) {
|
async function deleteUploads(callerUid, uid) {
|
||||||
|
|||||||
Reference in New Issue
Block a user