mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-11 16:35:47 +01:00
on user delete remove from ip sorted set, fix search by ip
This commit is contained in:
@@ -79,11 +79,14 @@ module.exports = function(User) {
|
||||
'uid:' + uid + ':favourites', 'uid:' + uid + ':followed_tids', 'user:' + uid + ':settings',
|
||||
'uid:' + uid + ':topics', 'uid:' + uid + ':posts',
|
||||
'uid:' + uid + ':chats', 'uid:' + uid + ':chats:unread',
|
||||
'uid:' + uid + ':ip', 'uid:' + uid + ':upvote', 'uid:' + uid + ':downvote',
|
||||
'uid:' + uid + ':upvote', 'uid:' + uid + ':downvote',
|
||||
'uid:' + uid + ':ignored:cids'
|
||||
];
|
||||
db.deleteAll(keys, next);
|
||||
},
|
||||
function(next) {
|
||||
deleteUserIps(uids, next);
|
||||
},
|
||||
function(next) {
|
||||
deleteUserFromFollowers(uid, next);
|
||||
},
|
||||
@@ -110,6 +113,23 @@ module.exports = function(User) {
|
||||
});
|
||||
};
|
||||
|
||||
function deleteUserIps(uid, callback) {
|
||||
db.getSortedSetRange('uid:' + uid + ':ip', 0, -1, function(err, ips) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
async.each(ips, function(ip, next) {
|
||||
db.sortedSetRemove('ip:' + ip + ':uid', uid, next);
|
||||
}, function(err) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
db.delete('uid:' + uid + ':ip', callback);
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
function deleteUserFromFollowers(uid, callback) {
|
||||
db.getSetMembers('followers:' + uid, function(err, uids) {
|
||||
if (err) {
|
||||
|
||||
@@ -18,7 +18,7 @@ module.exports = function(User) {
|
||||
return callback(null, {timing: 0, users: [], matchCount: 0, pages: []});
|
||||
}
|
||||
|
||||
if (searchBy === 'ip') {
|
||||
if (searchBy.indexOf('ip') !== -1) {
|
||||
return searchByIP(query, callback);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user