mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
Deprecated filter:user.delete hook
Please use static:user.delete instead.
This commit is contained in:
@@ -4,6 +4,9 @@ var winston = require('winston'),
|
|||||||
async = require('async');
|
async = require('async');
|
||||||
|
|
||||||
module.exports = function(Plugins) {
|
module.exports = function(Plugins) {
|
||||||
|
Plugins.deprecatedHooks = [
|
||||||
|
'filter:user.delete'
|
||||||
|
];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
`data` is an object consisting of (* is required):
|
`data` is an object consisting of (* is required):
|
||||||
@@ -23,6 +26,10 @@ module.exports = function(Plugins) {
|
|||||||
|
|
||||||
var method;
|
var method;
|
||||||
|
|
||||||
|
if (Plugins.deprecatedHooks.indexOf(data.hook) !== -1) {
|
||||||
|
winston.warn('[plugins/' + id + '] Hook `' + data.hook + '` is deprecated, please use an alternative');
|
||||||
|
}
|
||||||
|
|
||||||
if (data.hook && data.method) {
|
if (data.hook && data.method) {
|
||||||
data.id = id;
|
data.id = id;
|
||||||
if (!data.priority) {
|
if (!data.priority) {
|
||||||
|
|||||||
@@ -47,70 +47,79 @@ module.exports = function(User) {
|
|||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
async.parallel([
|
plugins.fireHook('static:user.delete', {
|
||||||
function(next) {
|
uid: uid
|
||||||
db.sortedSetRemove('username:uid', userData.username, next);
|
}, function(err) {
|
||||||
},
|
|
||||||
function(next) {
|
|
||||||
db.sortedSetRemove('username:sorted', userData.username.toLowerCase() + ':' + uid, next);
|
|
||||||
},
|
|
||||||
function(next) {
|
|
||||||
db.sortedSetRemove('userslug:uid', userData.userslug, next);
|
|
||||||
},
|
|
||||||
function(next) {
|
|
||||||
db.sortedSetRemove('fullname:uid', userData.fullname, next);
|
|
||||||
},
|
|
||||||
function(next) {
|
|
||||||
if (userData.email) {
|
|
||||||
async.parallel([
|
|
||||||
async.apply(db.sortedSetRemove, 'email:uid', userData.email.toLowerCase()),
|
|
||||||
async.apply(db.sortedSetRemove, 'email:sorted', userData.email.toLowerCase() + ':' + uid)
|
|
||||||
], next);
|
|
||||||
} else {
|
|
||||||
next();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
function(next) {
|
|
||||||
db.sortedSetsRemove([
|
|
||||||
'users:joindate',
|
|
||||||
'users:postcount',
|
|
||||||
'users:reputation',
|
|
||||||
'users:banned',
|
|
||||||
'users:online'
|
|
||||||
], uid, next);
|
|
||||||
},
|
|
||||||
function(next) {
|
|
||||||
db.decrObjectField('global', 'userCount', next);
|
|
||||||
},
|
|
||||||
function(next) {
|
|
||||||
var keys = [
|
|
||||||
'uid:' + uid + ':notifications:read', 'uid:' + uid + ':notifications:unread',
|
|
||||||
'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 + ':upvote', 'uid:' + uid + ':downvote',
|
|
||||||
'uid:' + uid + ':ignored:cids', 'uid:' + uid + ':flag:pids'
|
|
||||||
];
|
|
||||||
db.deleteAll(keys, next);
|
|
||||||
},
|
|
||||||
function(next) {
|
|
||||||
deleteUserIps(uid, next);
|
|
||||||
},
|
|
||||||
function(next) {
|
|
||||||
deleteUserFromFollowers(uid, next);
|
|
||||||
},
|
|
||||||
function(next) {
|
|
||||||
groups.leaveAllGroups(uid, next);
|
|
||||||
},
|
|
||||||
function(next) {
|
|
||||||
plugins.fireHook('filter:user.delete', uid, next);
|
|
||||||
}
|
|
||||||
], function(err) {
|
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
db.deleteAll(['followers:' + uid, 'following:' + uid, 'user:' + uid], callback);
|
async.parallel([
|
||||||
|
function(next) {
|
||||||
|
db.sortedSetRemove('username:uid', userData.username, next);
|
||||||
|
},
|
||||||
|
function(next) {
|
||||||
|
db.sortedSetRemove('username:sorted', userData.username.toLowerCase() + ':' + uid, next);
|
||||||
|
},
|
||||||
|
function(next) {
|
||||||
|
db.sortedSetRemove('userslug:uid', userData.userslug, next);
|
||||||
|
},
|
||||||
|
function(next) {
|
||||||
|
db.sortedSetRemove('fullname:uid', userData.fullname, next);
|
||||||
|
},
|
||||||
|
function(next) {
|
||||||
|
if (userData.email) {
|
||||||
|
async.parallel([
|
||||||
|
async.apply(db.sortedSetRemove, 'email:uid', userData.email.toLowerCase()),
|
||||||
|
async.apply(db.sortedSetRemove, 'email:sorted', userData.email.toLowerCase() + ':' + uid)
|
||||||
|
], next);
|
||||||
|
} else {
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
function(next) {
|
||||||
|
db.sortedSetsRemove([
|
||||||
|
'users:joindate',
|
||||||
|
'users:postcount',
|
||||||
|
'users:reputation',
|
||||||
|
'users:banned',
|
||||||
|
'users:online'
|
||||||
|
], uid, next);
|
||||||
|
},
|
||||||
|
function(next) {
|
||||||
|
db.decrObjectField('global', 'userCount', next);
|
||||||
|
},
|
||||||
|
function(next) {
|
||||||
|
var keys = [
|
||||||
|
'uid:' + uid + ':notifications:read', 'uid:' + uid + ':notifications:unread',
|
||||||
|
'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 + ':upvote', 'uid:' + uid + ':downvote',
|
||||||
|
'uid:' + uid + ':ignored:cids', 'uid:' + uid + ':flag:pids'
|
||||||
|
];
|
||||||
|
db.deleteAll(keys, next);
|
||||||
|
},
|
||||||
|
function(next) {
|
||||||
|
deleteUserIps(uid, next);
|
||||||
|
},
|
||||||
|
function(next) {
|
||||||
|
deleteUserFromFollowers(uid, next);
|
||||||
|
},
|
||||||
|
function(next) {
|
||||||
|
groups.leaveAllGroups(uid, next);
|
||||||
|
},
|
||||||
|
function(next) {
|
||||||
|
// Deprecated as of v0.7.4, remove in v1.0.0
|
||||||
|
plugins.fireHook('filter:user.delete', uid, next);
|
||||||
|
}
|
||||||
|
], function(err) {
|
||||||
|
if (err) {
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
db.deleteAll(['followers:' + uid, 'following:' + uid, 'user:' + uid], callback);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user