feat: #8349, remove user posts from queue if user is deleted

v1.18.x
Barış Soner Uşaklı 5 years ago
parent e603ebc0c6
commit 5a2b515431

@ -29,6 +29,7 @@ module.exports = function (User) {
await deletePosts(callerUid, uid);
await deleteTopics(callerUid, uid);
await deleteUploads(uid);
await deleteQueued(uid);
const userData = await User.deleteAccount(uid);
return userData;
};
@ -58,6 +59,14 @@ module.exports = function (User) {
}, { alwaysStartAt: 0 });
}
async function deleteQueued(uid) {
await batch.processSortedSet('post:queue', async function (ids) {
const data = await db.getObjects(ids.map(id => 'post:queue:' + id));
const deleteIds = data.filter(d => parseInt(d.uid, 10) === parseInt(uid, 10)).map(d => d.id);
await async.eachSeries(deleteIds, posts.removeFromQueue);
}, { alwaysStartAt: 0 });
}
async function removeFromSortedSets(uid) {
await db.sortedSetsRemove([
'users:joindate',

Loading…
Cancel
Save