Skip to content

Node.js based forum software built for the modern web

on user delete remove from ip sorted set, fix search by ip

barisusakli03ae7db56154
diff --git a/src/user/delete.js b/src/user/delete.js
index c115c727f1..b13fa1aa97 100644
--- a/src/user/delete.js
+++ b/src/user/delete.js
@@ -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) {
diff --git a/src/user/search.js b/src/user/search.js
index 1ea83a863f..a95b64bfaa 100644
--- a/src/user/search.js
+++ b/src/user/search.js
@@ -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);
}