|
|
|
@ -4,6 +4,7 @@ var async = require('async'),
|
|
|
|
|
db = require('../database'),
|
|
|
|
|
posts = require('../posts'),
|
|
|
|
|
topics = require('../topics'),
|
|
|
|
|
favourites = require('../favourites'),
|
|
|
|
|
groups = require('../groups'),
|
|
|
|
|
plugins = require('../plugins'),
|
|
|
|
|
batch = require('../batch');
|
|
|
|
@ -21,12 +22,35 @@ module.exports = function(User) {
|
|
|
|
|
function(next) {
|
|
|
|
|
deleteTopics(uid, next);
|
|
|
|
|
},
|
|
|
|
|
function(next) {
|
|
|
|
|
deleteVotes(uid, next);
|
|
|
|
|
},
|
|
|
|
|
function(next) {
|
|
|
|
|
User.deleteAccount(uid, next);
|
|
|
|
|
}
|
|
|
|
|
], callback);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function deleteVotes(uid, callback) {
|
|
|
|
|
async.waterfall([
|
|
|
|
|
function (next) {
|
|
|
|
|
async.parallel({
|
|
|
|
|
upvotedPids: async.apply(db.getSortedSetRange, 'uid:' + uid + ':upvote', 0, -1),
|
|
|
|
|
downvotedPids: async.apply(db.getSortedSetRange, 'uid:' + uid + ':downvote', 0, -1)
|
|
|
|
|
}, next);
|
|
|
|
|
},
|
|
|
|
|
function (pids, next) {
|
|
|
|
|
pids = pids.upvotedPids.concat(pids.downvotedPids).filter(function(pid, index, array) {
|
|
|
|
|
return pid && array.indexOf(pid) === index;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
async.eachLimit(pids, 50, function(pid, next) {
|
|
|
|
|
favourites.unvote(pid, uid, next);
|
|
|
|
|
}, next);
|
|
|
|
|
}
|
|
|
|
|
], callback);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function deletePosts(uid, callback) {
|
|
|
|
|
deleteSortedSetElements('uid:' + uid + ':posts', posts.purge, callback);
|
|
|
|
|
}
|
|
|
|
|