This commit is contained in:
Julian Lam
2018-05-04 12:39:00 -04:00
parent 96d2980472
commit 8e275df803
5 changed files with 33 additions and 7 deletions

View File

@@ -203,6 +203,15 @@ module.exports = function (SocketUser) {
SocketUser.toggleBlock = function (socket, data, callback) {
async.waterfall([
function (next) {
user.blocks.can(data.uid, function (err, can) {
if (err || !can) {
return next(err || new Error('[[error:cannot-block-privileged]]'));
}
next();
});
},
async.apply(user.blocks.is, data.uid, socket.uid),
function (is, next) {
user.blocks[is ? 'remove' : 'add'](data.uid, socket.uid, next);