Verificação de termos enviados

O servidor agora não irá permitir o envio de termos com caracteres que não sejam permitidos e, caso o filtro de temas adultos da sala esteja habilitado, irá proibir palavras filtradas também.
This commit is contained in:
luca0N! 2021-01-02 23:57:43 -03:00
parent 5c70dc6b87
commit bcf698074b
Signed by: luca0N
GPG Key ID: 68FDED9A81B90723
1 changed files with 13 additions and 0 deletions

View File

@ -324,6 +324,19 @@ wss.on('connection', ws => {
break;
}
// Verificar termo via expressão regular.
let palavraRegexIlegal = new RegExp(vars["palavra.regex.caracteresIlegais"], 'g');
if (palavraRegexIlegal.test(resposta.extra.termo)){
ws.send(JSON.stringify(new Resposta("PEDIDO_CANCELADO", "SERVIDOR", "PALAVRA_OU_LETRA_PROIBIDO", { erroDescrição: "TERMO_CARACTERES_ILEGAIS" })));
break;
}
// Verificar se o termo enviado possui termos filtrados CASO a sala tinha o filtro habilitado
if (salaObj.opções["filtro.temasAdultos.habilitado"] && Util.filtrarMensagem(resposta.extra.termo, filtros) !== resposta.extra.termo){
ws.send(JSON.stringify(new Resposta("PEDIDO_CANCELADO", "SERVIDOR", "PALAVRA_OU_LETRA_PROIBIDO", { erroDescrição: "TERMO_IMPRÓPRIO" })));
break;
}
// Verificar o tipo do termo enviado.
let letra = resposta.extra.termo.length === 1;
let salaClientes = salaObj.clientes;