From ea0653f08ba7c38a11f3e741f53b88fbe4807734 Mon Sep 17 00:00:00 2001 From: adb Date: Wed, 11 Nov 2020 00:21:04 +0100 Subject: [PATCH] renaming disabled --- api.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/api.js b/api.js index f591ff5..602752d 100644 --- a/api.js +++ b/api.js @@ -34,13 +34,19 @@ wss.on('connection', (ws, req) => { ws.send('{"type":"route","path":"/login"}') }else if (msg.content.text === "") ws.send(JSON.stringify({type: "error", content: "your message was empty"})) + else if (msg.content.text.length >= 1000) + ws.send(JSON.stringify({type: "error", content: "your message is too long"})) else{ msg.content.user = thisuser //msg.content.text = msg.content.text.replace(//g, ">").replace(/\n/g, "
") wss.clients.forEach(client => client.send(JSON.stringify(msg))) } else if (msg.type === 'login' && msg.content.user !== ""){ - if (msg.content.user.length >= 20) ws.send(JSON.stringify({type: "error", content: "username is too long"})) + if (thisuser !== ""){ + ws.send(JSON.stringify({type: "error", content: "you are already logged in"})) + ws.send('{"type":"route","path":"/chat"}') + } + else if (msg.content.user.length >= 20) ws.send(JSON.stringify({type: "error", content: "username is too long"})) else if (msg.content.user === "you" || user.indexOf(msg.content.user) !== -1) ws.send(JSON.stringify({type: "error", content: "username already exist"})) else{