Limit the number of characters allowed in mod actions reasons

This commit is contained in:
Joimer 2013-11-05 09:51:18 +01:00
parent d27ceb40b9
commit db69d52a42

View File

@ -13,6 +13,8 @@
var crypto = require('crypto');
const MAX_REASON_LENGTH = 300;
var commands = exports.commands = {
version: function(target, room, user) {
@ -443,6 +445,9 @@ var commands = exports.commands = {
if (room.isPrivate && room.auth) {
return this.sendReply('You can\'t warn here: This is a privately-owned room not subject to global rules.');
}
if (target.length > MAX_REASON_LENGTH) {
return this.sendReply('The reason is too long. It cannot excede ' + MAX_REASON_LENGTH + ' characters.');
}
if (!this.can('warn', targetUser, room)) return false;
this.addModCommand(''+targetUser.name+' was warned by '+user.name+'.' + (target ? " (" + target + ")" : ""));
@ -483,6 +488,9 @@ var commands = exports.commands = {
if (!targetUser) {
return this.sendReply('User '+this.targetUsername+' not found.');
}
if (target.length > MAX_REASON_LENGTH) {
return this.sendReply('The reason is too long. It cannot excede ' + MAX_REASON_LENGTH + ' characters.');
}
if (!this.can('mute', targetUser, room)) return false;
if (targetUser.mutedRooms[room.id] || targetUser.locked || !targetUser.connected) {
var problem = ' but was already '+(!targetUser.connected ? 'offline' : targetUser.locked ? 'locked' : 'muted');
@ -510,6 +518,9 @@ var commands = exports.commands = {
if (!targetUser) {
return this.sendReply('User '+this.targetUsername+' not found.');
}
if (target.length > MAX_REASON_LENGTH) {
return this.sendReply('The reason is too long. It cannot excede ' + MAX_REASON_LENGTH + ' characters.');
}
if (!this.can('mute', targetUser, room)) return false;
if (((targetUser.mutedRooms[room.id] && (targetUser.muteDuration[room.id]||0) >= 50*60*1000) || targetUser.locked) && !target) {
@ -554,6 +565,9 @@ var commands = exports.commands = {
if (!targetUser) {
return this.sendReply('User '+this.targetUser+' not found.');
}
if (target.length > MAX_REASON_LENGTH) {
return this.sendReply('The reason is too long. It cannot excede ' + MAX_REASON_LENGTH + ' characters.');
}
if (!user.can('lock', targetUser)) {
return this.sendReply('/lock - Access denied.');
}
@ -598,6 +612,9 @@ var commands = exports.commands = {
if (!targetUser) {
return this.sendReply('User '+this.targetUsername+' not found.');
}
if (target.length > MAX_REASON_LENGTH) {
return this.sendReply('The reason is too long. It cannot excede ' + MAX_REASON_LENGTH + ' characters.');
}
if (!this.can('ban', targetUser)) return false;
if (Users.checkBanned(targetUser.latestIp) && !target && !targetUser.connected) {
@ -679,6 +696,9 @@ var commands = exports.commands = {
modnote: function(target, room, user, connection, cmd) {
if (!target) return this.parse('/help note');
if (target.length > MAX_REASON_LENGTH) {
return this.sendReply('The note is too long. It cannot excede ' + MAX_REASON_LENGTH + ' characters.');
}
if (!this.can('mute')) return false;
return this.privateModCommand('(' + user.name + ' notes: ' + target + ')');
},