- new file pour handler request allListUser
    - add function on button new conversation in chat
    - remove cookies from js
Django
    - fix new_msg.sender.id
This commit is contained in:
Kum1ta
2024-08-26 01:27:32 +02:00
parent b08a90226a
commit 1c9e985320
5 changed files with 70 additions and 38 deletions

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/31 22:17:24 by edbernar #+# #+# */
/* Updated: 2024/08/25 18:09:25 by edbernar ### ########.fr */
/* Updated: 2024/08/25 23:25:30 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
@ -28,23 +28,7 @@ const errorFunction = [typeErrorInvalidPassword, typeErrorInvalidToken42, typeEr
let status = 0;
function getCookie(name)
{
const value = `; ${document.cookie}`;
const parts = value.split(`; ${name}=`);
let token = null;
if (parts.length === 2)
{
token = parts.pop().split(';').shift();
token = token.substring(1, token.length - 1);
}
return (token);
}
socket.onopen = () => {
let token = getCookie("token");
status = 1;
console.log('Connected');
};
@ -92,21 +76,10 @@ function sendRequest(type, content) {
coc = JSON.stringify(content);
else
coc = content;
if (getCookie("token"))
{
socket.send(JSON.stringify({
type: type,
token: getCookie("token"),
content: content
}));
}
else
{
socket.send(JSON.stringify({
type: type,
content: content
}));
}
socket.send(JSON.stringify({
type: type,
content: content
}));
}
export { socket, sendRequest };