mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-11 08:25:46 +01:00
delete chats on user delete
This commit is contained in:
@@ -55,6 +55,9 @@ module.exports = function(User) {
|
|||||||
function (next) {
|
function (next) {
|
||||||
deleteVotes(uid, next);
|
deleteVotes(uid, next);
|
||||||
},
|
},
|
||||||
|
function (next) {
|
||||||
|
deleteChats(uid, next);
|
||||||
|
},
|
||||||
function (next) {
|
function (next) {
|
||||||
async.parallel([
|
async.parallel([
|
||||||
function(next) {
|
function(next) {
|
||||||
@@ -97,6 +100,7 @@ module.exports = function(User) {
|
|||||||
'uid:' + uid + ':favourites', 'uid:' + uid + ':followed_tids', 'user:' + uid + ':settings',
|
'uid:' + uid + ':favourites', 'uid:' + uid + ':followed_tids', 'user:' + uid + ':settings',
|
||||||
'uid:' + uid + ':topics', 'uid:' + uid + ':posts',
|
'uid:' + uid + ':topics', 'uid:' + uid + ':posts',
|
||||||
'uid:' + uid + ':chats', 'uid:' + uid + ':chats:unread',
|
'uid:' + uid + ':chats', 'uid:' + uid + ':chats:unread',
|
||||||
|
'uid:' + uid + ':chat:rooms', 'uid:' + uid + ':chat:rooms:unread',
|
||||||
'uid:' + uid + ':upvote', 'uid:' + uid + ':downvote',
|
'uid:' + uid + ':upvote', 'uid:' + uid + ':downvote',
|
||||||
'uid:' + uid + ':ignored:cids', 'uid:' + uid + ':flag:pids'
|
'uid:' + uid + ':ignored:cids', 'uid:' + uid + ':flag:pids'
|
||||||
];
|
];
|
||||||
@@ -145,6 +149,29 @@ module.exports = function(User) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deleteChats(uid, callback) {
|
||||||
|
async.waterfall([
|
||||||
|
function (next) {
|
||||||
|
db.getSortedSetRange('uid:' + uid + ':chat:rooms', 0, -1, next);
|
||||||
|
},
|
||||||
|
function (roomIds, next) {
|
||||||
|
var userKeys = roomIds.map(function(roomId) {
|
||||||
|
return 'uid:' + uid + ':chat:room:' + roomId + ':mids';
|
||||||
|
});
|
||||||
|
var roomKeys = roomIds.map(function(roomId) {
|
||||||
|
return 'chat:room:' + roomId + ':uids';
|
||||||
|
});
|
||||||
|
|
||||||
|
async.parallel([
|
||||||
|
async.apply(db.sortedSetsRemove, roomKeys, uid),
|
||||||
|
async.apply(db.deleteAll, userKeys)
|
||||||
|
], next);
|
||||||
|
}
|
||||||
|
], function(err) {
|
||||||
|
callback(err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function deleteUserIps(uid, callback) {
|
function deleteUserIps(uid, callback) {
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function (next) {
|
function (next) {
|
||||||
|
|||||||
Reference in New Issue
Block a user