refactor ban messaging; add ban duration to message; use bootbox instead of alert

This commit is contained in:
psychobunny
2017-05-05 19:31:49 -04:00
parent 76a2b4800b
commit b3bd70235a
5 changed files with 28 additions and 17 deletions

View File

@@ -7,6 +7,7 @@ var websockets = require('../index');
var events = require('../../events');
var privileges = require('../../privileges');
var plugins = require('../../plugins');
var translator = require('../../translator');
module.exports = function (SocketUser) {
SocketUser.banUsers = function (socket, data, callback) {
@@ -99,7 +100,20 @@ module.exports = function (SocketUser) {
user.ban(uid, until, reason, next);
},
function (next) {
websockets.in('uid_' + uid).emit('event:banned');
console.log(reason);
if (!reason) {
return translator.translate('[[user:info.banned-no-reason]]', function (translated) {
next(false, translated);
});
}
next(false, reason);
},
function (_reason, next) {
websockets.in('uid_' + uid).emit('event:banned', {
until: until,
reason: _reason,
});
next();
},
], callback);