From 76465732d1c9d065e3c1dde0b2d28e382e6697de Mon Sep 17 00:00:00 2001 From: NigeParis Date: Tue, 16 Dec 2025 18:32:42 +0100 Subject: [PATCH 01/30] Error with Master pino creahes changed to pino-pretty --- frontend/src/pages/login/login.ts | 1 - frontend/src/pages/root/pong_box_image.png | Bin 0 -> 25973 bytes frontend/src/pages/root/root.ts | 1 - src/auth/src/run.ts | 2 +- src/chat/src/run.ts | 2 +- src/user/src/run.ts | 2 +- 6 files changed, 3 insertions(+), 5 deletions(-) create mode 100644 frontend/src/pages/root/pong_box_image.png diff --git a/frontend/src/pages/login/login.ts b/frontend/src/pages/login/login.ts index f128455..352aba5 100644 --- a/frontend/src/pages/login/login.ts +++ b/frontend/src/pages/login/login.ts @@ -96,7 +96,6 @@ async function handleOtp( } } } - inputs[0].focus(); } diff --git a/frontend/src/pages/root/pong_box_image.png b/frontend/src/pages/root/pong_box_image.png new file mode 100644 index 0000000000000000000000000000000000000000..b9a870ea7987c8c53b0c207e245053b9b23d4e7e GIT binary patch literal 25973 zcmeAS@N?(olHy`uVBq!ia0y~yVB%z8VD#W%V_;yo)t9@5fk9+bRY*ihP-3}4K~a8M zW=^U?No7H*LTW{38UsVct*f&l%br+Nwcg*zrO)_zgG|r!3ih~t`?=jTmaaMR?p5CY zh*d!bnv)p*J>*+(=HLAPcF*?z@X~Y@4qmzQY0l3sU9Mh$G)z3O5NW@->?7t`1wzT?SsqtB{#$lt&I?9IF9zW=Ik{r`WV zZ1It+f0lawm>D*Ezn%TO@|S-XeAhp8{l~xGCrax?-}HZew}<V6+u{{8Zg0{^f{SN`y5wXMi6ui?~P6R>hhWwr*}e^c@D_T2IvFIUAL(>uQO z-bVw`>-+!a{(IN@e8u!R!8*T%O`kozI`_;Wt4r(o^}0_T(O&VA?Z@B0zo&naI+3s| zah=YF+llksd!E#ZhVSU)i<$AGX40EeRkjTRh9yZxdJ`CD$9m`)FMd>8*yj)?bY#hD z{)_xZ4}v~*d;XGeQnM^!PcHT^{2ny_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root/root.ts +++ b/frontend/src/pages/root/root.ts @@ -11,7 +11,6 @@ addRoute('/', async (_: string): Promise => { return page; }, { bypass_auth: true }) - addRoute('/with_title/:title', (_: string, args: RouteHandlerParams) => { setTitle(args.title) console.log(`title should be '${args.title}'`); diff --git a/src/auth/src/run.ts b/src/auth/src/run.ts index 1e8f129..d3d410f 100644 --- a/src/auth/src/run.ts +++ b/src/auth/src/run.ts @@ -7,7 +7,7 @@ const start = async () => { const envToLogger = { development: { transport: { - target: 'pino', + target: 'pino-pretty', options: { translateTime: 'HH:MM:ss Z', ignore: 'pid,hostname', diff --git a/src/chat/src/run.ts b/src/chat/src/run.ts index f7b78ca..d9f1e2a 100644 --- a/src/chat/src/run.ts +++ b/src/chat/src/run.ts @@ -7,7 +7,7 @@ const start = async () => { const envToLogger = { development: { transport: { - target: 'pino', + target: 'pino-pretty', options: { translateTime: 'HH:MM:ss Z', ignore: 'pid,hostname', diff --git a/src/user/src/run.ts b/src/user/src/run.ts index 1e8f129..d3d410f 100644 --- a/src/user/src/run.ts +++ b/src/user/src/run.ts @@ -7,7 +7,7 @@ const start = async () => { const envToLogger = { development: { transport: { - target: 'pino', + target: 'pino-pretty', options: { translateTime: 'HH:MM:ss Z', ignore: 'pid,hostname', From 4e4ad367c21a874ee425f9295d2da9219a1e4613 Mon Sep 17 00:00:00 2001 From: NigeParis Date: Wed, 17 Dec 2025 09:57:41 +0100 Subject: [PATCH 02/30] WIP Blocked users and clean up obj { } its in constitant --- frontend/src/pages/chat/chat.ts | 103 ++++++++----------------- frontend/src/pages/chat/types_front.ts | 1 + src/chat/src/app.ts | 100 ++++++++++++++++++++++-- src/chat/src/chat_types.ts | 1 + 4 files changed, 129 insertions(+), 76 deletions(-) diff --git a/frontend/src/pages/chat/chat.ts b/frontend/src/pages/chat/chat.ts index ac10778..985216a 100644 --- a/frontend/src/pages/chat/chat.ts +++ b/frontend/src/pages/chat/chat.ts @@ -23,6 +23,14 @@ export const color = { reset: '', }; + +export type blockedUnBlocked = +{ + userState: string, + userTarget: string, + by: string, +}; + // get the name of the machine used to connect const machineHostName = window.location.hostname; console.log('connect to login at %chttps://' + machineHostName + ':8888/app/login',color.yellow); @@ -64,22 +72,6 @@ function actionBtnPopUpInvite(invite: ClientProfil, senderSocket: Socket) { }, 0) }; -// async function windowStateHidden() { -// const socketId = __socket || undefined; -// // let oldName = localStorage.getItem("oldName") ?? undefined; -// let oldName: string; -// if (socketId === undefined) return; -// let userName = await updateUser(); -// oldName = userName?.name ?? ""; -// if (oldName === "") return; -// localStorage.setItem('oldName', oldName); -// socketId.emit('client_left', { -// user: userName?.name, -// why: 'tab window hidden - socket not dead', -// }); -// return; -// }; - async function windowStateVisable() { const buddies = document.getElementById('div-buddies') as HTMLDivElement; @@ -141,36 +133,6 @@ function parseCmdMsg(msgText: string): string[] | undefined { return command; } -// async function listBuddies(socket: Socket, buddies: HTMLDivElement, listBuddies: string) { - -// if (!buddies) return; -// const sendtextbox = document.getElementById('t-chat-window') as HTMLButtonElement; -// const buddiesElement = document.createElement("div-buddies-list"); -// buddiesElement.textContent = listBuddies + '\n'; -// const user = getUser()?.name ?? ""; -// buddies.appendChild(buddiesElement); -// buddies.scrollTop = buddies.scrollHeight; -// console.log(`Added buddies: ${listBuddies}`); - -// buddiesElement.style.cursor = "pointer"; -// buddiesElement.addEventListener("click", () => { -// navigator.clipboard.writeText(listBuddies); -// if (listBuddies !== user && user !== "") { -// sendtextbox.value = `@${listBuddies}: `; -// console.log("Copied to clipboard:", listBuddies); -// sendtextbox.focus(); -// } -// }); - -// buddiesElement.addEventListener("dblclick", () => { -// console.log("Open profile:", listBuddies); -// getProfil(socket, listBuddies); -// sendtextbox.value = ""; -// }); - -// } - - function waitSocketConnected(socket: Socket): Promise { return new Promise(resolve => { if (socket.connected) return resolve(); @@ -270,30 +232,6 @@ async function whoami(socket: Socket) { } }; -// async function openProfilePopup(profil: ClientProfil) { - - -// const modalname = document.getElementById("modal-name") ?? null; -// if (modalname) -// modalname.innerHTML = ` -//
-// Profil of ${profil.user}
-// Login Name: '${profil.loginName ?? 'Guest'}' -//
-// Login ID: '${profil.userID ?? ''}' -//
-// -// -// -//
About: '${profil.text}'
-// -// `; -// const profilList = document.getElementById("profile-modal") ?? null; -// if (profilList) -// profilList.classList.remove("hidden"); -// // The popup now exists → attach the event -// } - let count = 0; function incrementCounter(): number { count += 1; @@ -336,6 +274,7 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn await waitSocketConnected(socket); console.log("I AM Connected to the server:", socket.id); const user = getUser()?.name; + const userID = getUser()?.id; // Ensure we have a user AND socket is connected if (!user || !socket.connected) return; const message = { @@ -347,6 +286,8 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn text: " has Just ARRIVED in the chat", timestamp: Date.now(), SenderWindowID: socket.id, + SenderID: userID, + }; socket.emit('message', JSON.stringify(message)); const messageElement = document.createElement("div"); @@ -397,7 +338,12 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn }); socket.on('profilMessage', (profil: ClientProfil) => { + profil.SenderID = getUser()?.id ?? ""; + profil.SenderName = getUser()?.name ?? ""; openProfilePopup(profil); + console.log(`DEBUG LOG: userId:${profil.userID}: senderID ${profil.SenderID}' senderID:${getUser()?.id}`); + console.log(`DEBUG LOG: user:${profil.user}: sender:${profil.SenderName}' senderID:${getUser()?.name}`); + socket.emit('check_Block_button', profil); actionBtnPopUpClear(profil, socket); actionBtnPopUpInvite(profil, socket); actionBtnPopUpBlock(profil, socket); @@ -416,13 +362,25 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn let icon = '⛔'; const chatWindow = document.getElementById("t-chatbox") as HTMLDivElement; const messageElement = document.createElement("div"); - if (`${blocked.text}` === '\'I have un-blocked you\'' ) { icon = '💚'}; + if (`${blocked.text}` === 'I have un-blocked you' ) { icon = '💚'}; messageElement.innerText =`${icon}${blocked.SenderName}: ${blocked.text}`; chatWindow.appendChild(messageElement); chatWindow.scrollTop = chatWindow.scrollHeight; }); + socket.on('blockBtn', (data: blockedUnBlocked) => { + const blockUserBtn = document.querySelector("#popup-b-block"); + if (blockUserBtn) { + + console.log(' =================== >>> User State:', data.userState); + console.log(' =================== >>> UserTarget:', data.userTarget); + console.log(' =================== >>> By:', data.by); + let message = ""; + if (data.userState === "block") {message = "un-block"} else{message = "block"} + blockUserBtn.textContent = message; + } + }); socket.on('logout', () => { @@ -553,6 +511,7 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn break; default: const user = getUser()?.name; + const userID = getUser()?.id; // Ensure we have a user AND socket is connected if (!user || !socket.connected) return; const message = { @@ -564,6 +523,8 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn text: msgCommand[1], timestamp: Date.now(), SenderWindowID: socket.id, + SenderID: userID, + }; //socket.emit('MsgObjectServer', message); socket.emit('privMessage', JSON.stringify(message)); diff --git a/frontend/src/pages/chat/types_front.ts b/frontend/src/pages/chat/types_front.ts index 807d071..913095a 100644 --- a/frontend/src/pages/chat/types_front.ts +++ b/frontend/src/pages/chat/types_front.ts @@ -18,6 +18,7 @@ export type ClientProfil = { timestamp: number, SenderWindowID:string, SenderName: string, + SenderID: string, Sendertext: string, innerHtml?: string, }; \ No newline at end of file diff --git a/src/chat/src/app.ts b/src/chat/src/app.ts index e348ecd..7f9e5c5 100644 --- a/src/chat/src/app.ts +++ b/src/chat/src/app.ts @@ -39,6 +39,32 @@ interface ClientInfo { lastSeen: number; } + +export type blockedUnBlocked = +{ + userState: string, + userTarget: string, + by: string, +}; + + +export type obj = +{ + command: string, + destination: string, + type: string, + user: string, + frontendUserName: string, + frontendUser: string, + token: string, + text: string, + timestamp: number, + SenderWindowID: string, + Sendertext: string, +}; + + + // function setAboutPlayer(about: string): string { // if (!about) { // about = 'Player is good Shape - This is a default description'; @@ -107,10 +133,45 @@ declare module 'fastify' { client_left: (userName: string, why: string) => void; list: (oldUser: string, user: string) => void; updateClientName: (oldUser: string, user: string) => void; + blockBtn: (data: blockedUnBlocked) => void; + check_Block_button: (data: blockedUnBlocked) => void; }>; } } + + +/** + * function get the object user in an array of users[] by name + * @param users + * @param name + * @returns + */ +function getUserById(users: User[], id: string) { + return users.find(user => user.id === id) || null; +}; + +function isUser_BlockedBy_me(fastify: FastifyInstance, blockedBy_Id : string, isBlocked_Id: string): string { + const users: User[] = fastify.db.getAllUsers() ?? []; + if (!users) return ''; + const UserToBlock: User | null = getUserById(users, `${isBlocked_Id}`); + const UserAskingToBlock: User | null = getUserById(users, `${blockedBy_Id}`); + if (!UserToBlock) {console.log(color.blue, `'User: ${UserAskingToBlock?.id} has not blocked' ${isBlocked_Id}`); return ""}; + if (!UserAskingToBlock) {console.log(color.blue, `'User: ${UserToBlock?.id} has not blocked by' ${blockedBy_Id}`); return ""}; + const usersBlocked: BlockedData[] = fastify.db.getAllBlockedUsers() ?? []; + const userAreBlocked: boolean = isBlocked(UserAskingToBlock, UserToBlock, usersBlocked); + if (userAreBlocked) { + console.log(color.yellow, `'User :${UserAskingToBlock.name}) Hhas UN blocked ${UserToBlock.name}`) + return UserAskingToBlock.name; + } + console.log(color.blue, `'User :${UserAskingToBlock.name}) has BBBblocked ${UserToBlock.name}`) + + return ""; +}; + + + + async function onReady(fastify: FastifyInstance) { @@ -141,6 +202,8 @@ async function onReady(fastify: FastifyInstance) { list_SocketListener(fastify, socket); + + // socket.on('list', (object) => { // const userFromFrontend = object || null; @@ -264,15 +327,18 @@ async function onReady(fastify: FastifyInstance) { ); if (clientName !== null) { - const obj = { + const obj: obj = { command: prvMessage.command, destination: 'privateMsg', type: 'chat', user: clientName, token: '', text: prvMessage.text, + frontendUserName: '', + frontendUser: '', timestamp: Date.now(), SenderWindowID: socket.id, + Sendertext: '', }; // console.log(color.blue, 'DEBUG LOG: PRIV MESSAGE OUT :', obj.SenderWindowID); sendPrivMessage(fastify, obj, obj.SenderWindowID); @@ -309,6 +375,8 @@ async function onReady(fastify: FastifyInstance) { } }); + + socket.on('blockUser', async (data: string) => { const clientName: string = clientChat.get(socket.id)?.user || ''; const profilBlock: ClientProfil = JSON.parse(data) || ''; @@ -320,10 +388,13 @@ async function onReady(fastify: FastifyInstance) { console.log(color.yellow, UserToBlock); console.log(color.yellow, `user Asking to block: ${profilBlock.SenderName}`); console.log(color.yellow, UserAskingToBlock); + console.log(color.red, clientName); const usersBlocked: BlockedData[] = fastify.db.getAllBlockedUsers() ?? []; if (!UserAskingToBlock || !UserToBlock || !usersBlocked) return; const userAreBlocked: boolean = isBlocked(UserAskingToBlock, UserToBlock, usersBlocked); + isUser_BlockedBy_me(fastify, UserAskingToBlock!.id, UserToBlock!.id); + if (userAreBlocked) { console.log(color.green, 'Both users are blocked as requested'); @@ -333,17 +404,19 @@ async function onReady(fastify: FastifyInstance) { console.log(color.red, 'ALL BLOCKED USERS:', usersBlocked); fastify.db.removeBlockedUserFor(UserAskingToBlock!.id, UserToBlock!.id); const usersBlocked2 = fastify.db.getAllBlockedUsers(); - console.log(color.green, 'remove ALL BLOCKED USERS:', usersBlocked2); + console.log(color.green, 'remove A BLOCKED USER:', usersBlocked2); if (clientName !== null) { const blockedMessage = 'I have un-blocked you'; if (clientName !== null) { - const obj = { + const obj: obj = { command: 'message', destination: 'privateMsg', type: 'chat', user: clientName, token: '', text: '', + frontendUserName: '', + frontendUser: '', timestamp: Date.now(), SenderWindowID: socket.id, Sendertext: 'You have un-blocked', @@ -354,6 +427,14 @@ async function onReady(fastify: FastifyInstance) { } // profilBlock.Sendertext = `'You have un-blocked '`; sendBlocked(fastify, blockedMessage, profilBlock); + const message: blockedUnBlocked = + { + userState: "un-block", + userTarget: "", + by: "", + + }; + socket.emit('blockBtn', message); } } else { @@ -367,7 +448,7 @@ async function onReady(fastify: FastifyInstance) { const blockedMessage = 'I have blocked you'; profilBlock.Sendertext = 'You have blocked '; if (clientName !== null) { - const obj = { + const obj: obj = { command: 'message', destination: 'privateMsg', type: 'chat', @@ -383,6 +464,14 @@ async function onReady(fastify: FastifyInstance) { // clientChat.delete(obj.user); } sendBlocked(fastify, blockedMessage, profilBlock); + const message: blockedUnBlocked = + { + userState: "block", + userTarget: UserToBlock.name, + by: UserAskingToBlock.name, + + }; + socket.emit('blockBtn', message); } } }); @@ -416,7 +505,7 @@ async function onReady(fastify: FastifyInstance) { `Client entered the Chat: ${clientName} (${socket.id})`, ); if (clientName !== null) { - const obj = { + const obj: obj = { command: '', destination: 'system-info', type: 'chat', @@ -427,6 +516,7 @@ async function onReady(fastify: FastifyInstance) { text: text, timestamp: Date.now(), SenderWindowID: socket.id, + Sendertext: "", }; broadcast(fastify, obj, obj.SenderWindowID); } diff --git a/src/chat/src/chat_types.ts b/src/chat/src/chat_types.ts index 5ed14f9..0377659 100644 --- a/src/chat/src/chat_types.ts +++ b/src/chat/src/chat_types.ts @@ -17,6 +17,7 @@ export type ClientProfil = { timestamp: number, SenderWindowID:string, SenderName: string, + SenderID: string, Sendertext: string, innerHtml?: string, From fb68487786c15fbb051d2ffd2d88444791757268 Mon Sep 17 00:00:00 2001 From: NigeParis Date: Wed, 17 Dec 2025 10:20:07 +0100 Subject: [PATCH 03/30] Cleaned un the type obj - now consistant through out --- frontend/src/pages/chat/chat.ts | 19 +++++++++++++++++-- src/chat/src/app.ts | 21 +++++++++++++++------ 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/frontend/src/pages/chat/chat.ts b/frontend/src/pages/chat/chat.ts index 985216a..2790626 100644 --- a/frontend/src/pages/chat/chat.ts +++ b/frontend/src/pages/chat/chat.ts @@ -31,6 +31,21 @@ export type blockedUnBlocked = by: string, }; +export type obj = +{ + command: string, + destination: string, + type: string, + user: string, + frontendUserName: string, + frontendUser: string, + token: string, + text: string, + timestamp: number, + SenderWindowID: string, + Sendertext: string, +}; + // get the name of the machine used to connect const machineHostName = window.location.hostname; console.log('connect to login at %chttps://' + machineHostName + ':8888/app/login',color.yellow); @@ -242,7 +257,7 @@ async function openMessagePopup(message: string) { const modalmessage = document.getElementById("modal-message") ?? null; if(!message) return - const obj:any = JSON.parse(message); + const obj:string = JSON.parse(message); if (modalmessage) { const messageElement = document.createElement("div"); messageElement.innerHTML = ` @@ -341,7 +356,7 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn profil.SenderID = getUser()?.id ?? ""; profil.SenderName = getUser()?.name ?? ""; openProfilePopup(profil); - console.log(`DEBUG LOG: userId:${profil.userID}: senderID ${profil.SenderID}' senderID:${getUser()?.id}`); + console.log(`DEBUG LOG: userId:${profil.userID}: senderID${profil.SenderID}' senderID:${getUser()?.id}`); console.log(`DEBUG LOG: user:${profil.user}: sender:${profil.SenderName}' senderID:${getUser()?.name}`); socket.emit('check_Block_button', profil); actionBtnPopUpClear(profil, socket); diff --git a/src/chat/src/app.ts b/src/chat/src/app.ts index 7f9e5c5..bf27c55 100644 --- a/src/chat/src/app.ts +++ b/src/chat/src/app.ts @@ -189,7 +189,7 @@ async function onReady(fastify: FastifyInstance) { socket.on('message', (message: string) => { // console.info(color.blue, 'DEBUG LOG: Socket connected!', color.reset, socket.id); // console.log( color.blue, 'DEBUG LOG: Received message from client', color.reset, message); - const obj: ClientMessage = JSON.parse(message) as ClientMessage; + const obj: obj = JSON.parse(message) as ClientMessage; clientChat.set(socket.id, { user: obj.user, lastSeen: Date.now() }); // console.log(color.green, 'DEBUG LOG: Message from client', color.reset, `Sender: login name: ${obj.user} - windowID ${obj.SenderWindowID} - text message: ${obj.text}`); socket.emit('welcome', { msg: 'Welcome to the chat! : ' }); @@ -247,15 +247,18 @@ async function onReady(fastify: FastifyInstance) { if (!clientName) return; console.log(color.green, `Client logging out: ${clientName} (${socket.id})`); - const obj = { + const obj: obj = { command: '', destination: 'system-info', type: 'chat' as const, user: clientName, token: '', text: 'LEFT the chat', - timestamp: Date.now(), - SenderWindowID: socket.id, + frontendUserName: '', + frontendUser: '', + timestamp: Date.now(), + SenderWindowID: socket.id, + Sendertext: '', }; broadcast(fastify, obj, socket.id); // Optional: remove from map @@ -274,15 +277,18 @@ async function onReady(fastify: FastifyInstance) { if (reason === 'transport error') return; if (clientName !== null) { - const obj = { + const obj: obj = { command: '', destination: 'system-info', type: 'chat', user: clientName, token: '', text: 'LEFT the chat', + frontendUserName: '', + frontendUser: '', timestamp: Date.now(), SenderWindowID: socket.id, + Sendertext: '', }; broadcast(fastify, obj, obj.SenderWindowID); @@ -299,15 +305,18 @@ async function onReady(fastify: FastifyInstance) { ); if (clientName !== null) { - const obj = { + const obj: obj = { command: '', destination: 'system-info', type: 'chat', user: clientName, token: '', text: 'LEFT the chat but the window is still open', + frontendUserName: '', + frontendUser: '', timestamp: Date.now(), SenderWindowID: socket.id, + Sendertext: '', }; // console.log(color.blue, 'DEBUG LOG: BROADCASTS OUT :', obj.SenderWindowID); From eb1b3472cbeba885a853d2d0654c4a53bdcc42f4 Mon Sep 17 00:00:00 2001 From: NigeParis Date: Wed, 17 Dec 2025 12:03:28 +0100 Subject: [PATCH 04/30] clean up obj --- Docker.mk | 5 ++--- src/chat/src/app.ts | 2 ++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Docker.mk b/Docker.mk index e6f820b..f63b928 100644 --- a/Docker.mk +++ b/Docker.mk @@ -3,10 +3,10 @@ # ::: :::::::: # # Docker.mk :+: :+: :+: # # +:+ +:+ +:+ # -# By: maiboyer +#+ +:+ +#+ # +# By: nrobinso +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2025/06/11 18:10:26 by maiboyer #+# #+# # -# Updated: 2025/12/12 14:56:10 by maiboyer ### ########.fr # +# Updated: 2025/12/17 11:34:56 by nrobinso ### ########.fr # # # # **************************************************************************** # @@ -21,7 +21,6 @@ DOCKER_SERVICE= \ nginx \ user \ - all: build docker compose up -d $(DOCKER_SERVICE) diff --git a/src/chat/src/app.ts b/src/chat/src/app.ts index bf27c55..c0860fb 100644 --- a/src/chat/src/app.ts +++ b/src/chat/src/app.ts @@ -465,6 +465,8 @@ async function onReady(fastify: FastifyInstance) { token: '', text: '', timestamp: Date.now(), + frontendUserName: '', + frontendUser: '', SenderWindowID: socket.id, Sendertext: 'You have blocked', }; From a1d6c4ae9cef5a28d27f0b78476ac0cb2206bab8 Mon Sep 17 00:00:00 2001 From: NigeParis Date: Wed, 17 Dec 2025 13:20:01 +0100 Subject: [PATCH 05/30] block button in profil toggles with block or un blocked --- .../src/pages/chat/actionBtnPopUpBlock.ts | 2 +- frontend/src/pages/chat/chat.ts | 10 +- src/chat/src/app.ts | 121 ++++++++++++------ 3 files changed, 86 insertions(+), 47 deletions(-) diff --git a/frontend/src/pages/chat/actionBtnPopUpBlock.ts b/frontend/src/pages/chat/actionBtnPopUpBlock.ts index 0e65bcb..1c12b9d 100644 --- a/frontend/src/pages/chat/actionBtnPopUpBlock.ts +++ b/frontend/src/pages/chat/actionBtnPopUpBlock.ts @@ -6,7 +6,7 @@ export function actionBtnPopUpBlock(block: ClientProfil, senderSocket: Socket) { setTimeout(() => { const blockUserBtn = document.querySelector("#popup-b-block"); blockUserBtn?.addEventListener("click", () => { - block.text = ''; + block.text = ''; blockUser(block, senderSocket); }); }, 0) diff --git a/frontend/src/pages/chat/chat.ts b/frontend/src/pages/chat/chat.ts index 2790626..fe31df4 100644 --- a/frontend/src/pages/chat/chat.ts +++ b/frontend/src/pages/chat/chat.ts @@ -261,8 +261,8 @@ async function openMessagePopup(message: string) { if (modalmessage) { const messageElement = document.createElement("div"); messageElement.innerHTML = ` -
-
Next Game Message ${incrementCounter()}: ${obj.link}
+
Next Game Message ${incrementCounter()}: ${obj}
`; modalmessage.appendChild(messageElement); modalmessage.scrollTop = modalmessage.scrollHeight; @@ -356,6 +356,7 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn profil.SenderID = getUser()?.id ?? ""; profil.SenderName = getUser()?.name ?? ""; openProfilePopup(profil); + socket.emit('isBlockdBtn', profil); console.log(`DEBUG LOG: userId:${profil.userID}: senderID${profil.SenderID}' senderID:${getUser()?.id}`); console.log(`DEBUG LOG: user:${profil.user}: sender:${profil.SenderName}' senderID:${getUser()?.name}`); socket.emit('check_Block_button', profil); @@ -375,9 +376,10 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn socket.on('blockUser', (blocked: ClientProfil) => { let icon = '⛔'; + const chatWindow = document.getElementById("t-chatbox") as HTMLDivElement; const messageElement = document.createElement("div"); - if (`${blocked.text}` === 'I have un-blocked you' ) { icon = '💚'}; + if (`${blocked.text}` === 'I have un-blocked you' ) {icon = '💚'}; messageElement.innerText =`${icon}${blocked.SenderName}: ${blocked.text}`; chatWindow.appendChild(messageElement); chatWindow.scrollTop = chatWindow.scrollHeight; @@ -418,7 +420,7 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn setTimeout(() => { connected(socket); - }, 0); + }, 16); if (window.location.pathname === '/app/chat') { console.log('%cWindow is focused on /chat:' + socket.id, color.green); if (socket.id) { diff --git a/src/chat/src/app.ts b/src/chat/src/app.ts index c0860fb..8ee238e 100644 --- a/src/chat/src/app.ts +++ b/src/chat/src/app.ts @@ -134,6 +134,7 @@ declare module 'fastify' { list: (oldUser: string, user: string) => void; updateClientName: (oldUser: string, user: string) => void; blockBtn: (data: blockedUnBlocked) => void; + isBlockdBtn: (data: blockedUnBlocked) => void; check_Block_button: (data: blockedUnBlocked) => void; }>; } @@ -189,7 +190,7 @@ async function onReady(fastify: FastifyInstance) { socket.on('message', (message: string) => { // console.info(color.blue, 'DEBUG LOG: Socket connected!', color.reset, socket.id); // console.log( color.blue, 'DEBUG LOG: Received message from client', color.reset, message); - const obj: obj = JSON.parse(message) as ClientMessage; + const obj: ClientMessage = JSON.parse(message) as ClientMessage; clientChat.set(socket.id, { user: obj.user, lastSeen: Date.now() }); // console.log(color.green, 'DEBUG LOG: Message from client', color.reset, `Sender: login name: ${obj.user} - windowID ${obj.SenderWindowID} - text message: ${obj.text}`); socket.emit('welcome', { msg: 'Welcome to the chat! : ' }); @@ -202,27 +203,6 @@ async function onReady(fastify: FastifyInstance) { list_SocketListener(fastify, socket); - - - // socket.on('list', (object) => { - - // const userFromFrontend = object || null; - // const client = clientChat.get(socket.id) || null; - - // //console.log(color.red, 'DEBUG LOG: list activated', userFromFrontend, color.reset, socket.id); - - // if (userFromFrontend.oldUser !== userFromFrontend.user) { - // //console.log(color.red, 'DEBUG LOG: list activated', userFromFrontend.oldUser, color.reset); - // // if (client?.user === null) { - // // console.log('ERROR: clientName is NULL'); - // // return; - // // }; - // if (client) { - // client.user = userFromFrontend.user; - // } - // } - // connectedUser(fastify.io, socket.id); - // }); socket.on('updateClientName', (object) => { const userFromFrontend = object || null; @@ -384,6 +364,42 @@ async function onReady(fastify: FastifyInstance) { } }); + socket.on('isBlockdBtn', async (data: ClientProfil) => { + const profilBlock: ClientProfil = data || ''; + const users: User[] = fastify.db.getAllUsers() ?? []; + const UserToBlock: User | null = getUserByName(users, `${profilBlock.user}`); + const UserAskingToBlock: User | null = getUserByName(users, `${profilBlock.SenderName}`); + + console.log(color.yellow, `user to block: ${profilBlock.user}`); + console.log(color.yellow, UserToBlock); + console.log(color.yellow, `user Asking to block: ${profilBlock.SenderName}`); + console.log(color.yellow, UserAskingToBlock); + + if (!UserAskingToBlock || !UserToBlock) return; + + if(isUser_BlockedBy_me(fastify, UserAskingToBlock!.id, UserToBlock!.id)) { + const message: blockedUnBlocked = + { + userState: "block", + userTarget: UserToBlock.name, + by: UserAskingToBlock.name, + + + }; + socket.emit('blockBtn', message); + } else { + + const message: blockedUnBlocked = + { + userState: "un-block", + userTarget: UserToBlock.name, + by: UserAskingToBlock.name, + + }; + socket.emit('blockBtn', message); + + + } }); socket.on('blockUser', async (data: string) => { @@ -393,16 +409,37 @@ async function onReady(fastify: FastifyInstance) { const UserToBlock: User | null = getUserByName(users, `${profilBlock.user}`); const UserAskingToBlock: User | null = getUserByName(users, `${profilBlock.SenderName}`); - console.log(color.yellow, `user to block: ${profilBlock.user}`); - console.log(color.yellow, UserToBlock); - console.log(color.yellow, `user Asking to block: ${profilBlock.SenderName}`); - console.log(color.yellow, UserAskingToBlock); - console.log(color.red, clientName); + // console.log(color.yellow, `user to block: ${profilBlock.user}`); + // console.log(color.yellow, UserToBlock); + // console.log(color.yellow, `user Asking to block: ${profilBlock.SenderName}`); + // console.log(color.yellow, UserAskingToBlock); + // console.log(color.red, clientName); const usersBlocked: BlockedData[] = fastify.db.getAllBlockedUsers() ?? []; if (!UserAskingToBlock || !UserToBlock || !usersBlocked) return; const userAreBlocked: boolean = isBlocked(UserAskingToBlock, UserToBlock, usersBlocked); - isUser_BlockedBy_me(fastify, UserAskingToBlock!.id, UserToBlock!.id); + if(isUser_BlockedBy_me(fastify, UserAskingToBlock!.id, UserToBlock!.id)) { + const message: blockedUnBlocked = + { + userState: "un-block", + userTarget: "", + by: "", + + }; + socket.emit('blockBtn', message); + } else { + + const message: blockedUnBlocked = + { + userState: "block", + userTarget: UserToBlock.name, + by: UserAskingToBlock.name, + + }; + socket.emit('blockBtn', message); + + + } if (userAreBlocked) { @@ -436,14 +473,14 @@ async function onReady(fastify: FastifyInstance) { } // profilBlock.Sendertext = `'You have un-blocked '`; sendBlocked(fastify, blockedMessage, profilBlock); - const message: blockedUnBlocked = - { - userState: "un-block", - userTarget: "", - by: "", + // const message: blockedUnBlocked = + // { + // userState: "un-block", + // userTarget: "", + // by: "", - }; - socket.emit('blockBtn', message); + // }; + // socket.emit('blockBtn', message); } } else { @@ -475,14 +512,14 @@ async function onReady(fastify: FastifyInstance) { // clientChat.delete(obj.user); } sendBlocked(fastify, blockedMessage, profilBlock); - const message: blockedUnBlocked = - { - userState: "block", - userTarget: UserToBlock.name, - by: UserAskingToBlock.name, + // const message: blockedUnBlocked = + // { + // userState: "block", + // userTarget: UserToBlock.name, + // by: UserAskingToBlock.name, - }; - socket.emit('blockBtn', message); + // }; + // socket.emit('blockBtn', message); } } }); From 637229c8c873cedca4858615cd45ba201f9e972c Mon Sep 17 00:00:00 2001 From: NigeParis Date: Wed, 17 Dec 2025 17:21:06 +0100 Subject: [PATCH 06/30] Work in progress - blocage working on it ./app 206 --- frontend/src/pages/chat/broadcastMsg.ts | 14 ++++-- frontend/src/pages/chat/chat.ts | 44 ++++++++++--------- frontend/src/pages/chat/types_front.ts | 11 ++++- src/chat/src/app.ts | 57 ++++++++++++++++++++++--- src/chat/src/broadcast.ts | 3 ++ src/chat/src/chat_types.ts | 14 +++++- src/chat/src/color.ts | 8 ++++ src/chat/src/filter_Blocked_user.ts | 39 +++++++++++++++++ src/chat/src/getUserById.ts | 10 +++++ src/chat/src/isUser_BlockedBy_me.ts | 32 ++++++++++++++ src/chat/src/routes/broadcast.ts | 2 +- 11 files changed, 201 insertions(+), 33 deletions(-) create mode 100644 src/chat/src/color.ts create mode 100644 src/chat/src/filter_Blocked_user.ts create mode 100644 src/chat/src/getUserById.ts create mode 100644 src/chat/src/isUser_BlockedBy_me.ts diff --git a/frontend/src/pages/chat/broadcastMsg.ts b/frontend/src/pages/chat/broadcastMsg.ts index 51a1130..586243b 100644 --- a/frontend/src/pages/chat/broadcastMsg.ts +++ b/frontend/src/pages/chat/broadcastMsg.ts @@ -1,7 +1,7 @@ import { addMessage } from "./addMessage"; import { Socket } from 'socket.io-client'; import { getUser } from "@app/auth"; - +import type { ClientMessage } from "./types_front"; /** * function sends socket.emit to the backend to active and broadcast a message to all sockets * echos the message with addMessage to the sender @@ -13,15 +13,21 @@ export function broadcastMsg (socket: Socket, msgCommand: string[]): void { addMessage(msgText); const user = getUser(); if (user && socket?.connected) { - const message = { - command: msgCommand, + const message: ClientMessage = { + command: msgCommand[0], destination: '', type: "chat", user: user.name, token: document.cookie, text: msgText, timestamp: Date.now(), - SenderWindowID: socket.id, + SenderWindowID: socket.id ?? "", + SenderUserName: user.name, + SenderUserID: user.id, + userID: '', + frontendUserName: '', + frontendUser: '', + Sendertext: '', }; socket.emit('message', JSON.stringify(message)); } diff --git a/frontend/src/pages/chat/chat.ts b/frontend/src/pages/chat/chat.ts index fe31df4..65f4b3a 100644 --- a/frontend/src/pages/chat/chat.ts +++ b/frontend/src/pages/chat/chat.ts @@ -193,6 +193,7 @@ function logout(socket: Socket) { async function connected(socket: Socket): Promise { + setTimeout(async () => { try { const buddies = document.getElementById('div-buddies') as HTMLDivElement; const loggedIn = isLoggedIn(); @@ -201,24 +202,23 @@ async function connected(socket: Socket): Promise { let oldUser = localStorage.getItem("oldName") ?? ""; console.log('%coldUser:',color.yellow, oldUser); if (loggedIn?.name === undefined) {console.log('');return ;} - setTimeout(() => { oldUser = loggedIn.name ?? ""; - }, 0); - // const res = await client.guestLogin(); - let user = await updateUser(); - console.log('%cUser?name:',color.yellow, user?.name); - localStorage.setItem("oldName", oldUser); - buddies.textContent = ""; - socket.emit('list', { - oldUser: oldUser, - user: user?.name, - }); - } catch (e) { - console.error("Login error:", e); - showError('Failed to login: Unknown error'); - } -}; - + // const res = await client.guestLogin(); + let user = await updateUser(); + console.log('%cUser?name:',color.yellow, user?.name); + localStorage.setItem("oldName", oldUser); + buddies.textContent = ""; + socket.emit('list', { + oldUser: oldUser, + user: user?.name, + }); + } catch (e) { + console.error("Login error:", e); + showError('Failed to login: Unknown error'); + } + }, 16); + }; + async function whoami(socket: Socket) { try { const chatWindow = document.getElementById("t-chatbox") as HTMLDivElement; @@ -281,6 +281,8 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn let socket = getSocket(); + let blockMessage: boolean; + setTimeout(async () => { // Listen for the 'connect' event socket.on("connect", async () => { @@ -310,6 +312,7 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn systemWindow.appendChild(messageElement); systemWindow.scrollTop = systemWindow.scrollHeight; }); +}, 0); // Listen for messages from the server "MsgObjectServer" socket.on("MsgObjectServer", (data: { message: ClientMessage}) => { @@ -321,8 +324,8 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn if (bconnected) { connected(socket); } - - if (chatWindow && data.message.destination === "") { + console.log('stahe eeee :', blockMessage); + if (chatWindow && data.message.destination === "" && !blockMessage) { const messageElement = document.createElement("div"); messageElement.textContent = `${data.message.user}: ${data.message.text}`; chatWindow.appendChild(messageElement); @@ -394,7 +397,7 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn console.log(' =================== >>> UserTarget:', data.userTarget); console.log(' =================== >>> By:', data.by); let message = ""; - if (data.userState === "block") {message = "un-block"} else{message = "block"} + if (data.userState === "block") {message = "un-block", blockMessage = true} else{message = "block", blockMessage = false} blockUserBtn.textContent = message; } }); @@ -587,5 +590,6 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn }); } } + }; addRoute('/chat', handleChat, { bypass_auth: true }); \ No newline at end of file diff --git a/frontend/src/pages/chat/types_front.ts b/frontend/src/pages/chat/types_front.ts index 913095a..93f9ab6 100644 --- a/frontend/src/pages/chat/types_front.ts +++ b/frontend/src/pages/chat/types_front.ts @@ -1,9 +1,18 @@ export type ClientMessage = { command: string destination: string; + type: string, user: string; + userID: string, + token: string + frontendUserName: string, + frontendUser: string, text: string; - SenderWindowID: string; + SenderWindowID: string, + SenderUserName: string, + SenderUserID: string, + timestamp: number, + Sendertext: string, }; diff --git a/src/chat/src/app.ts b/src/chat/src/app.ts index 8ee238e..fac6cb4 100644 --- a/src/chat/src/app.ts +++ b/src/chat/src/app.ts @@ -20,6 +20,7 @@ import { sendProfil } from './sendProfil'; import { setGameLink } from './setGameLink'; import { nextGame_SocketListener } from './nextGame_SocketListener'; import { list_SocketListener } from './list_SocketListener'; +import { filter_Blocked_user } from './filter_Blocked_user' // colors for console.log export const color = { @@ -196,6 +197,37 @@ async function onReady(fastify: FastifyInstance) { socket.emit('welcome', { msg: 'Welcome to the chat! : ' }); // Send object directly — DO NOT wrap it in a string broadcast(fastify, obj, obj.SenderWindowID); + + const users: User[] = fastify.db.getAllUsers() ?? []; + console.log('DEBUG: senderWindow :', getUserById(users, obj.SenderUserID)?.name); + + + + + fastify.io.fetchSockets().then((sockets) => { + for (const socket of sockets) { + const clientInfo = clientChat.get(socket.id); + if (!clientInfo?.user) { + console.log(color.yellow, `Skipping socket ${socket.id} (no user found)`); + continue; + } + console.log('DEBUG: UserIDWindow :', getUserByName(users, clientInfo.user)?.id); + const IDUser = getUserByName(users, clientInfo.user)?.id; + + console.log(filter_Blocked_user(fastify, obj, IDUser?? "")); + + + } + }); + + + + + + + + + // console.log(color.red, 'DEBUG LOG: connected in the Chat :', connectedUser(fastify.io), color.reset); }); @@ -227,7 +259,7 @@ async function onReady(fastify: FastifyInstance) { if (!clientName) return; console.log(color.green, `Client logging out: ${clientName} (${socket.id})`); - const obj: obj = { + const obj: ClientMessage = { command: '', destination: 'system-info', type: 'chat' as const, @@ -239,6 +271,9 @@ async function onReady(fastify: FastifyInstance) { timestamp: Date.now(), SenderWindowID: socket.id, Sendertext: '', + userID: '', + SenderUserName: '', + SenderUserID: '', }; broadcast(fastify, obj, socket.id); // Optional: remove from map @@ -257,7 +292,7 @@ async function onReady(fastify: FastifyInstance) { if (reason === 'transport error') return; if (clientName !== null) { - const obj: obj = { + const obj: ClientMessage = { command: '', destination: 'system-info', type: 'chat', @@ -269,6 +304,9 @@ async function onReady(fastify: FastifyInstance) { timestamp: Date.now(), SenderWindowID: socket.id, Sendertext: '', + userID: '', + SenderUserName: '', + SenderUserID: '', }; broadcast(fastify, obj, obj.SenderWindowID); @@ -285,7 +323,7 @@ async function onReady(fastify: FastifyInstance) { ); if (clientName !== null) { - const obj: obj = { + const obj: ClientMessage = { command: '', destination: 'system-info', type: 'chat', @@ -297,6 +335,9 @@ async function onReady(fastify: FastifyInstance) { timestamp: Date.now(), SenderWindowID: socket.id, Sendertext: '', + userID: '', + SenderUserName: '', + SenderUserID: '', }; // console.log(color.blue, 'DEBUG LOG: BROADCASTS OUT :', obj.SenderWindowID); @@ -316,7 +357,7 @@ async function onReady(fastify: FastifyInstance) { ); if (clientName !== null) { - const obj: obj = { + const obj: ClientMessage = { command: prvMessage.command, destination: 'privateMsg', type: 'chat', @@ -328,6 +369,9 @@ async function onReady(fastify: FastifyInstance) { timestamp: Date.now(), SenderWindowID: socket.id, Sendertext: '', + userID: '', + SenderUserName: '', + SenderUserID:'', }; // console.log(color.blue, 'DEBUG LOG: PRIV MESSAGE OUT :', obj.SenderWindowID); sendPrivMessage(fastify, obj, obj.SenderWindowID); @@ -553,7 +597,7 @@ async function onReady(fastify: FastifyInstance) { `Client entered the Chat: ${clientName} (${socket.id})`, ); if (clientName !== null) { - const obj: obj = { + const obj: ClientMessage = { command: '', destination: 'system-info', type: 'chat', @@ -565,6 +609,9 @@ async function onReady(fastify: FastifyInstance) { timestamp: Date.now(), SenderWindowID: socket.id, Sendertext: "", + userID: '', + SenderUserName: '', + SenderUserID: '', }; broadcast(fastify, obj, obj.SenderWindowID); } diff --git a/src/chat/src/broadcast.ts b/src/chat/src/broadcast.ts index 1d697fa..e028d7d 100644 --- a/src/chat/src/broadcast.ts +++ b/src/chat/src/broadcast.ts @@ -1,6 +1,7 @@ import type { ClientMessage } from './chat_types'; import { clientChat, color } from './app'; import { FastifyInstance } from 'fastify'; +import { getUserById } from './getUserById'; export function broadcast(fastify: FastifyInstance, data: ClientMessage, sender?: string) { fastify.io.fetchSockets().then((sockets) => { @@ -13,6 +14,8 @@ export function broadcast(fastify: FastifyInstance, data: ClientMessage, sender? console.log(color.yellow, `Skipping socket ${socket.id} (no user found)`); continue; } + // console.log('BLOCKED MAYBE', getUserById(sender)); + // console.log('TARGET',socket.id ); // Emit structured JSON object socket.emit('MsgObjectServer', { message: data }); // Debug logs diff --git a/src/chat/src/chat_types.ts b/src/chat/src/chat_types.ts index 0377659..05a938e 100644 --- a/src/chat/src/chat_types.ts +++ b/src/chat/src/chat_types.ts @@ -1,11 +1,21 @@ export type ClientMessage = { command: string destination: string; + type: string, user: string; + userID: string, + token: string + frontendUserName: string, + frontendUser: string, text: string; - SenderWindowID: string; + SenderWindowID: string, + SenderUserName: string, + SenderUserID: string, + timestamp: number, + Sendertext: string, }; + export type ClientProfil = { command: string, destination: string, @@ -21,4 +31,4 @@ export type ClientProfil = { Sendertext: string, innerHtml?: string, -}; \ No newline at end of file +}; diff --git a/src/chat/src/color.ts b/src/chat/src/color.ts new file mode 100644 index 0000000..cb87c2c --- /dev/null +++ b/src/chat/src/color.ts @@ -0,0 +1,8 @@ +// colors for console.log +export const color = { + red: '\x1b[31m', + green: '\x1b[32m', + yellow: '\x1b[33m', + blue: '\x1b[34m', + reset: '\x1b[0m', +}; \ No newline at end of file diff --git a/src/chat/src/filter_Blocked_user.ts b/src/chat/src/filter_Blocked_user.ts new file mode 100644 index 0000000..3f96bef --- /dev/null +++ b/src/chat/src/filter_Blocked_user.ts @@ -0,0 +1,39 @@ +import type { ClientMessage, ClientProfil } from './chat_types'; +import { FastifyInstance } from 'fastify'; +import type { User } from '@shared/database/mixin/user'; +import { getUserById } from './getUserById'; +import { isUser_BlockedBy_me } from './isUser_BlockedBy_me'; + +/** + * function to check if blocked or not - checks with ID + * @param fastify + * @param data + * @returns true or false - true if blocked user by a user + */ + +export function filter_Blocked_user(fastify: FastifyInstance, data: ClientMessage, id: string): boolean { + + const users: User[] = fastify.db.getAllUsers() ?? []; + const UserToBlock: string = id; + const UserAskingToBlock: User | null = getUserById(users,`${data.SenderUserID}`); + if (!UserAskingToBlock ) { + // console.log('SOMETHING NULL', data); + // console.log('UsetToBlock', UserToBlock?.id); + // console.log('UsetToBlock', UserToBlock?.name); + // console.log('UsetAskingToBlock', UserAskingToBlock?.id); + // console.log('UsetAskingToBlock', UserAskingToBlock?.name); + console.log(''); + + + return false; + } + if(isUser_BlockedBy_me(fastify, UserAskingToBlock!.id, UserToBlock)) + { + return true; + } + else + { + return false; + } +} + diff --git a/src/chat/src/getUserById.ts b/src/chat/src/getUserById.ts new file mode 100644 index 0000000..a276238 --- /dev/null +++ b/src/chat/src/getUserById.ts @@ -0,0 +1,10 @@ +import type { User } from '@shared/database/mixin/user'; +/** + * function get the object user in an array of users[] by name + * @param users + * @param name + * @returns + */ +export function getUserById(users: User[], id: string) { + return users.find(user => user.id === id) || null; +}; diff --git a/src/chat/src/isUser_BlockedBy_me.ts b/src/chat/src/isUser_BlockedBy_me.ts new file mode 100644 index 0000000..dcd7bb4 --- /dev/null +++ b/src/chat/src/isUser_BlockedBy_me.ts @@ -0,0 +1,32 @@ +import { FastifyInstance } from 'fastify'; +import type { User } from '@shared/database/mixin/user'; +import type { BlockedData } from '@shared/database/mixin/blocked'; +import { isBlocked } from './isBlocked'; +import { getUserById } from './getUserById'; +import { color } from './color'; + +/** + * checks the Db for the two matching Ids + * @param fastify + * @param blockedBy_Id + * @param isBlocked_Id + * @returns Null if not blocked + */ + +export function isUser_BlockedBy_me(fastify: FastifyInstance, blockedBy_Id : string, isBlocked_Id: string): string { + const users: User[] = fastify.db.getAllUsers() ?? []; + if (!users) return ''; + const UserToBlock: User | null = getUserById(users, `${isBlocked_Id}`); + const UserAskingToBlock: User | null = getUserById(users, `${blockedBy_Id}`); + if (!UserToBlock) {console.log(color.blue, `'User: ${UserAskingToBlock?.id} has not blocked' ${isBlocked_Id}`); return ""}; + if (!UserAskingToBlock) {console.log(color.blue, `'User: ${UserToBlock?.id} has not blocked by' ${blockedBy_Id}`); return ""}; + const usersBlocked: BlockedData[] = fastify.db.getAllBlockedUsers() ?? []; + const userAreBlocked: boolean = isBlocked(UserAskingToBlock, UserToBlock, usersBlocked); + if (userAreBlocked) { + console.log(color.yellow, `'User :${UserAskingToBlock.name}) Hhas UN blocked ${UserToBlock.name}`) + return UserAskingToBlock.name; + } + console.log(color.blue, `'User :${UserAskingToBlock.name}) has BBBblocked ${UserToBlock.name}`) + + return ""; +}; diff --git a/src/chat/src/routes/broadcast.ts b/src/chat/src/routes/broadcast.ts index 9bd0ec2..de46038 100644 --- a/src/chat/src/routes/broadcast.ts +++ b/src/chat/src/routes/broadcast.ts @@ -19,7 +19,7 @@ const route: FastifyPluginAsync = async (fastify): Promise => { config: { requireAuth: false }, }, async function(req, res) { - broadcast(this, { command: '', destination: '', user: 'CMwaLeSever!!', text: req.body.message, SenderWindowID: 'server' }); + //broadcast(this, { command: '', destination: '', user: 'CMwaLeSever!!', text: req.body.message, SenderWindowID: 'server' }); void res; }, ); From f5366bf9e1b22b0ff9798e39718e9f00bf6009f6 Mon Sep 17 00:00:00 2001 From: NigeParis Date: Wed, 17 Dec 2025 09:57:41 +0100 Subject: [PATCH 07/30] WIP Blocked users and clean up obj { } its in constitant --- frontend/src/pages/chat/chat.ts | 103 ++++++++----------------- frontend/src/pages/chat/types_front.ts | 1 + src/chat/src/app.ts | 100 ++++++++++++++++++++++-- src/chat/src/chat_types.ts | 1 + 4 files changed, 129 insertions(+), 76 deletions(-) diff --git a/frontend/src/pages/chat/chat.ts b/frontend/src/pages/chat/chat.ts index 5e890a2..7fa3051 100644 --- a/frontend/src/pages/chat/chat.ts +++ b/frontend/src/pages/chat/chat.ts @@ -23,6 +23,14 @@ export const color = { reset: '', }; + +export type blockedUnBlocked = +{ + userState: string, + userTarget: string, + by: string, +}; + // get the name of the machine used to connect const machineHostName = window.location.hostname; console.log('connect to login at %chttps://' + machineHostName + ':8888/app/login',color.yellow); @@ -64,22 +72,6 @@ function actionBtnPopUpInvite(invite: ClientProfil, senderSocket: Socket) { }, 0) }; -// async function windowStateHidden() { -// const socketId = __socket || undefined; -// // let oldName = localStorage.getItem("oldName") ?? undefined; -// let oldName: string; -// if (socketId === undefined) return; -// let userName = await updateUser(); -// oldName = userName?.name ?? ""; -// if (oldName === "") return; -// localStorage.setItem('oldName', oldName); -// socketId.emit('client_left', { -// user: userName?.name, -// why: 'tab window hidden - socket not dead', -// }); -// return; -// }; - async function windowStateVisable() { const buddies = document.getElementById('div-buddies') as HTMLDivElement; @@ -141,36 +133,6 @@ function parseCmdMsg(msgText: string): string[] | undefined { return command; } -// async function listBuddies(socket: Socket, buddies: HTMLDivElement, listBuddies: string) { - -// if (!buddies) return; -// const sendtextbox = document.getElementById('t-chat-window') as HTMLButtonElement; -// const buddiesElement = document.createElement("div-buddies-list"); -// buddiesElement.textContent = listBuddies + '\n'; -// const user = getUser()?.name ?? ""; -// buddies.appendChild(buddiesElement); -// buddies.scrollTop = buddies.scrollHeight; -// console.log(`Added buddies: ${listBuddies}`); - -// buddiesElement.style.cursor = "pointer"; -// buddiesElement.addEventListener("click", () => { -// navigator.clipboard.writeText(listBuddies); -// if (listBuddies !== user && user !== "") { -// sendtextbox.value = `@${listBuddies}: `; -// console.log("Copied to clipboard:", listBuddies); -// sendtextbox.focus(); -// } -// }); - -// buddiesElement.addEventListener("dblclick", () => { -// console.log("Open profile:", listBuddies); -// getProfil(socket, listBuddies); -// sendtextbox.value = ""; -// }); - -// } - - function waitSocketConnected(socket: Socket): Promise { return new Promise(resolve => { if (socket.connected) return resolve(); @@ -270,30 +232,6 @@ async function whoami(socket: Socket) { } }; -// async function openProfilePopup(profil: ClientProfil) { - - -// const modalname = document.getElementById("modal-name") ?? null; -// if (modalname) -// modalname.innerHTML = ` -//
-// Profil of ${profil.user}
-// Login Name: '${profil.loginName ?? 'Guest'}' -//
-// Login ID: '${profil.userID ?? ''}' -//
-// -// -// -//
About: '${profil.text}'
-// -// `; -// const profilList = document.getElementById("profile-modal") ?? null; -// if (profilList) -// profilList.classList.remove("hidden"); -// // The popup now exists → attach the event -// } - let count = 0; function incrementCounter(): number { count += 1; @@ -336,6 +274,7 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn await waitSocketConnected(socket); console.log("I AM Connected to the server:", socket.id); const user = getUser()?.name; + const userID = getUser()?.id; // Ensure we have a user AND socket is connected if (!user || !socket.connected) return; const message = { @@ -347,6 +286,8 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn text: " has Just ARRIVED in the chat", timestamp: Date.now(), SenderWindowID: socket.id, + SenderID: userID, + }; socket.emit('message', JSON.stringify(message)); const messageElement = document.createElement("div"); @@ -397,7 +338,12 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn }); socket.on('profilMessage', (profil: ClientProfil) => { + profil.SenderID = getUser()?.id ?? ""; + profil.SenderName = getUser()?.name ?? ""; openProfilePopup(profil); + console.log(`DEBUG LOG: userId:${profil.userID}: senderID ${profil.SenderID}' senderID:${getUser()?.id}`); + console.log(`DEBUG LOG: user:${profil.user}: sender:${profil.SenderName}' senderID:${getUser()?.name}`); + socket.emit('check_Block_button', profil); actionBtnPopUpClear(profil, socket); actionBtnPopUpInvite(profil, socket); actionBtnPopUpBlock(profil, socket); @@ -416,13 +362,25 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn let icon = '⛔'; const chatWindow = document.getElementById("t-chatbox") as HTMLDivElement; const messageElement = document.createElement("div"); - if (`${blocked.text}` === '\'I have un-blocked you\'' ) { icon = '💚'}; + if (`${blocked.text}` === 'I have un-blocked you' ) { icon = '💚'}; messageElement.innerText =`${icon}${blocked.SenderName}: ${blocked.text}`; chatWindow.appendChild(messageElement); chatWindow.scrollTop = chatWindow.scrollHeight; }); + socket.on('blockBtn', (data: blockedUnBlocked) => { + const blockUserBtn = document.querySelector("#popup-b-block"); + if (blockUserBtn) { + + console.log(' =================== >>> User State:', data.userState); + console.log(' =================== >>> UserTarget:', data.userTarget); + console.log(' =================== >>> By:', data.by); + let message = ""; + if (data.userState === "block") {message = "un-block"} else{message = "block"} + blockUserBtn.textContent = message; + } + }); socket.on('logout', () => { @@ -553,6 +511,7 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn break; default: const user = getUser()?.name; + const userID = getUser()?.id; // Ensure we have a user AND socket is connected if (!user || !socket.connected) return; const message = { @@ -564,6 +523,8 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn text: msgCommand[1], timestamp: Date.now(), SenderWindowID: socket.id, + SenderID: userID, + }; //socket.emit('MsgObjectServer', message); socket.emit('privMessage', JSON.stringify(message)); diff --git a/frontend/src/pages/chat/types_front.ts b/frontend/src/pages/chat/types_front.ts index 807d071..913095a 100644 --- a/frontend/src/pages/chat/types_front.ts +++ b/frontend/src/pages/chat/types_front.ts @@ -18,6 +18,7 @@ export type ClientProfil = { timestamp: number, SenderWindowID:string, SenderName: string, + SenderID: string, Sendertext: string, innerHtml?: string, }; \ No newline at end of file diff --git a/src/chat/src/app.ts b/src/chat/src/app.ts index e348ecd..7f9e5c5 100644 --- a/src/chat/src/app.ts +++ b/src/chat/src/app.ts @@ -39,6 +39,32 @@ interface ClientInfo { lastSeen: number; } + +export type blockedUnBlocked = +{ + userState: string, + userTarget: string, + by: string, +}; + + +export type obj = +{ + command: string, + destination: string, + type: string, + user: string, + frontendUserName: string, + frontendUser: string, + token: string, + text: string, + timestamp: number, + SenderWindowID: string, + Sendertext: string, +}; + + + // function setAboutPlayer(about: string): string { // if (!about) { // about = 'Player is good Shape - This is a default description'; @@ -107,10 +133,45 @@ declare module 'fastify' { client_left: (userName: string, why: string) => void; list: (oldUser: string, user: string) => void; updateClientName: (oldUser: string, user: string) => void; + blockBtn: (data: blockedUnBlocked) => void; + check_Block_button: (data: blockedUnBlocked) => void; }>; } } + + +/** + * function get the object user in an array of users[] by name + * @param users + * @param name + * @returns + */ +function getUserById(users: User[], id: string) { + return users.find(user => user.id === id) || null; +}; + +function isUser_BlockedBy_me(fastify: FastifyInstance, blockedBy_Id : string, isBlocked_Id: string): string { + const users: User[] = fastify.db.getAllUsers() ?? []; + if (!users) return ''; + const UserToBlock: User | null = getUserById(users, `${isBlocked_Id}`); + const UserAskingToBlock: User | null = getUserById(users, `${blockedBy_Id}`); + if (!UserToBlock) {console.log(color.blue, `'User: ${UserAskingToBlock?.id} has not blocked' ${isBlocked_Id}`); return ""}; + if (!UserAskingToBlock) {console.log(color.blue, `'User: ${UserToBlock?.id} has not blocked by' ${blockedBy_Id}`); return ""}; + const usersBlocked: BlockedData[] = fastify.db.getAllBlockedUsers() ?? []; + const userAreBlocked: boolean = isBlocked(UserAskingToBlock, UserToBlock, usersBlocked); + if (userAreBlocked) { + console.log(color.yellow, `'User :${UserAskingToBlock.name}) Hhas UN blocked ${UserToBlock.name}`) + return UserAskingToBlock.name; + } + console.log(color.blue, `'User :${UserAskingToBlock.name}) has BBBblocked ${UserToBlock.name}`) + + return ""; +}; + + + + async function onReady(fastify: FastifyInstance) { @@ -141,6 +202,8 @@ async function onReady(fastify: FastifyInstance) { list_SocketListener(fastify, socket); + + // socket.on('list', (object) => { // const userFromFrontend = object || null; @@ -264,15 +327,18 @@ async function onReady(fastify: FastifyInstance) { ); if (clientName !== null) { - const obj = { + const obj: obj = { command: prvMessage.command, destination: 'privateMsg', type: 'chat', user: clientName, token: '', text: prvMessage.text, + frontendUserName: '', + frontendUser: '', timestamp: Date.now(), SenderWindowID: socket.id, + Sendertext: '', }; // console.log(color.blue, 'DEBUG LOG: PRIV MESSAGE OUT :', obj.SenderWindowID); sendPrivMessage(fastify, obj, obj.SenderWindowID); @@ -309,6 +375,8 @@ async function onReady(fastify: FastifyInstance) { } }); + + socket.on('blockUser', async (data: string) => { const clientName: string = clientChat.get(socket.id)?.user || ''; const profilBlock: ClientProfil = JSON.parse(data) || ''; @@ -320,10 +388,13 @@ async function onReady(fastify: FastifyInstance) { console.log(color.yellow, UserToBlock); console.log(color.yellow, `user Asking to block: ${profilBlock.SenderName}`); console.log(color.yellow, UserAskingToBlock); + console.log(color.red, clientName); const usersBlocked: BlockedData[] = fastify.db.getAllBlockedUsers() ?? []; if (!UserAskingToBlock || !UserToBlock || !usersBlocked) return; const userAreBlocked: boolean = isBlocked(UserAskingToBlock, UserToBlock, usersBlocked); + isUser_BlockedBy_me(fastify, UserAskingToBlock!.id, UserToBlock!.id); + if (userAreBlocked) { console.log(color.green, 'Both users are blocked as requested'); @@ -333,17 +404,19 @@ async function onReady(fastify: FastifyInstance) { console.log(color.red, 'ALL BLOCKED USERS:', usersBlocked); fastify.db.removeBlockedUserFor(UserAskingToBlock!.id, UserToBlock!.id); const usersBlocked2 = fastify.db.getAllBlockedUsers(); - console.log(color.green, 'remove ALL BLOCKED USERS:', usersBlocked2); + console.log(color.green, 'remove A BLOCKED USER:', usersBlocked2); if (clientName !== null) { const blockedMessage = 'I have un-blocked you'; if (clientName !== null) { - const obj = { + const obj: obj = { command: 'message', destination: 'privateMsg', type: 'chat', user: clientName, token: '', text: '', + frontendUserName: '', + frontendUser: '', timestamp: Date.now(), SenderWindowID: socket.id, Sendertext: 'You have un-blocked', @@ -354,6 +427,14 @@ async function onReady(fastify: FastifyInstance) { } // profilBlock.Sendertext = `'You have un-blocked '`; sendBlocked(fastify, blockedMessage, profilBlock); + const message: blockedUnBlocked = + { + userState: "un-block", + userTarget: "", + by: "", + + }; + socket.emit('blockBtn', message); } } else { @@ -367,7 +448,7 @@ async function onReady(fastify: FastifyInstance) { const blockedMessage = 'I have blocked you'; profilBlock.Sendertext = 'You have blocked '; if (clientName !== null) { - const obj = { + const obj: obj = { command: 'message', destination: 'privateMsg', type: 'chat', @@ -383,6 +464,14 @@ async function onReady(fastify: FastifyInstance) { // clientChat.delete(obj.user); } sendBlocked(fastify, blockedMessage, profilBlock); + const message: blockedUnBlocked = + { + userState: "block", + userTarget: UserToBlock.name, + by: UserAskingToBlock.name, + + }; + socket.emit('blockBtn', message); } } }); @@ -416,7 +505,7 @@ async function onReady(fastify: FastifyInstance) { `Client entered the Chat: ${clientName} (${socket.id})`, ); if (clientName !== null) { - const obj = { + const obj: obj = { command: '', destination: 'system-info', type: 'chat', @@ -427,6 +516,7 @@ async function onReady(fastify: FastifyInstance) { text: text, timestamp: Date.now(), SenderWindowID: socket.id, + Sendertext: "", }; broadcast(fastify, obj, obj.SenderWindowID); } diff --git a/src/chat/src/chat_types.ts b/src/chat/src/chat_types.ts index 5ed14f9..0377659 100644 --- a/src/chat/src/chat_types.ts +++ b/src/chat/src/chat_types.ts @@ -17,6 +17,7 @@ export type ClientProfil = { timestamp: number, SenderWindowID:string, SenderName: string, + SenderID: string, Sendertext: string, innerHtml?: string, From e543116b5d5e8cd59c12014fc830cae42ec346e7 Mon Sep 17 00:00:00 2001 From: NigeParis Date: Wed, 17 Dec 2025 10:20:07 +0100 Subject: [PATCH 08/30] Cleaned un the type obj - now consistant through out --- frontend/src/pages/chat/chat.ts | 19 +++++++++++++++++-- src/chat/src/app.ts | 21 +++++++++++++++------ 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/frontend/src/pages/chat/chat.ts b/frontend/src/pages/chat/chat.ts index 7fa3051..1047911 100644 --- a/frontend/src/pages/chat/chat.ts +++ b/frontend/src/pages/chat/chat.ts @@ -31,6 +31,21 @@ export type blockedUnBlocked = by: string, }; +export type obj = +{ + command: string, + destination: string, + type: string, + user: string, + frontendUserName: string, + frontendUser: string, + token: string, + text: string, + timestamp: number, + SenderWindowID: string, + Sendertext: string, +}; + // get the name of the machine used to connect const machineHostName = window.location.hostname; console.log('connect to login at %chttps://' + machineHostName + ':8888/app/login',color.yellow); @@ -242,7 +257,7 @@ async function openMessagePopup(message: string) { const modalmessage = document.getElementById("modal-message") ?? null; if(!message) return - const obj:any = JSON.parse(message); + const obj:string = JSON.parse(message); if (modalmessage) { const messageElement = document.createElement("div"); messageElement.innerHTML = ` @@ -341,7 +356,7 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn profil.SenderID = getUser()?.id ?? ""; profil.SenderName = getUser()?.name ?? ""; openProfilePopup(profil); - console.log(`DEBUG LOG: userId:${profil.userID}: senderID ${profil.SenderID}' senderID:${getUser()?.id}`); + console.log(`DEBUG LOG: userId:${profil.userID}: senderID${profil.SenderID}' senderID:${getUser()?.id}`); console.log(`DEBUG LOG: user:${profil.user}: sender:${profil.SenderName}' senderID:${getUser()?.name}`); socket.emit('check_Block_button', profil); actionBtnPopUpClear(profil, socket); diff --git a/src/chat/src/app.ts b/src/chat/src/app.ts index 7f9e5c5..bf27c55 100644 --- a/src/chat/src/app.ts +++ b/src/chat/src/app.ts @@ -189,7 +189,7 @@ async function onReady(fastify: FastifyInstance) { socket.on('message', (message: string) => { // console.info(color.blue, 'DEBUG LOG: Socket connected!', color.reset, socket.id); // console.log( color.blue, 'DEBUG LOG: Received message from client', color.reset, message); - const obj: ClientMessage = JSON.parse(message) as ClientMessage; + const obj: obj = JSON.parse(message) as ClientMessage; clientChat.set(socket.id, { user: obj.user, lastSeen: Date.now() }); // console.log(color.green, 'DEBUG LOG: Message from client', color.reset, `Sender: login name: ${obj.user} - windowID ${obj.SenderWindowID} - text message: ${obj.text}`); socket.emit('welcome', { msg: 'Welcome to the chat! : ' }); @@ -247,15 +247,18 @@ async function onReady(fastify: FastifyInstance) { if (!clientName) return; console.log(color.green, `Client logging out: ${clientName} (${socket.id})`); - const obj = { + const obj: obj = { command: '', destination: 'system-info', type: 'chat' as const, user: clientName, token: '', text: 'LEFT the chat', - timestamp: Date.now(), - SenderWindowID: socket.id, + frontendUserName: '', + frontendUser: '', + timestamp: Date.now(), + SenderWindowID: socket.id, + Sendertext: '', }; broadcast(fastify, obj, socket.id); // Optional: remove from map @@ -274,15 +277,18 @@ async function onReady(fastify: FastifyInstance) { if (reason === 'transport error') return; if (clientName !== null) { - const obj = { + const obj: obj = { command: '', destination: 'system-info', type: 'chat', user: clientName, token: '', text: 'LEFT the chat', + frontendUserName: '', + frontendUser: '', timestamp: Date.now(), SenderWindowID: socket.id, + Sendertext: '', }; broadcast(fastify, obj, obj.SenderWindowID); @@ -299,15 +305,18 @@ async function onReady(fastify: FastifyInstance) { ); if (clientName !== null) { - const obj = { + const obj: obj = { command: '', destination: 'system-info', type: 'chat', user: clientName, token: '', text: 'LEFT the chat but the window is still open', + frontendUserName: '', + frontendUser: '', timestamp: Date.now(), SenderWindowID: socket.id, + Sendertext: '', }; // console.log(color.blue, 'DEBUG LOG: BROADCASTS OUT :', obj.SenderWindowID); From c41a32e4b1f251b321a4a7c6a1fee7e4011de9ff Mon Sep 17 00:00:00 2001 From: NigeParis Date: Wed, 17 Dec 2025 12:03:28 +0100 Subject: [PATCH 09/30] clean up obj --- Docker.mk | 5 ++--- src/chat/src/app.ts | 2 ++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Docker.mk b/Docker.mk index e6f820b..f63b928 100644 --- a/Docker.mk +++ b/Docker.mk @@ -3,10 +3,10 @@ # ::: :::::::: # # Docker.mk :+: :+: :+: # # +:+ +:+ +:+ # -# By: maiboyer +#+ +:+ +#+ # +# By: nrobinso +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2025/06/11 18:10:26 by maiboyer #+# #+# # -# Updated: 2025/12/12 14:56:10 by maiboyer ### ########.fr # +# Updated: 2025/12/17 11:34:56 by nrobinso ### ########.fr # # # # **************************************************************************** # @@ -21,7 +21,6 @@ DOCKER_SERVICE= \ nginx \ user \ - all: build docker compose up -d $(DOCKER_SERVICE) diff --git a/src/chat/src/app.ts b/src/chat/src/app.ts index bf27c55..c0860fb 100644 --- a/src/chat/src/app.ts +++ b/src/chat/src/app.ts @@ -465,6 +465,8 @@ async function onReady(fastify: FastifyInstance) { token: '', text: '', timestamp: Date.now(), + frontendUserName: '', + frontendUser: '', SenderWindowID: socket.id, Sendertext: 'You have blocked', }; From 8500d7dbe2ef291af2ad3ab9b4162647611771ac Mon Sep 17 00:00:00 2001 From: NigeParis Date: Wed, 17 Dec 2025 13:20:01 +0100 Subject: [PATCH 10/30] block button in profil toggles with block or un blocked --- .../src/pages/chat/actionBtnPopUpBlock.ts | 2 +- frontend/src/pages/chat/chat.ts | 10 +- src/chat/src/app.ts | 121 ++++++++++++------ 3 files changed, 86 insertions(+), 47 deletions(-) diff --git a/frontend/src/pages/chat/actionBtnPopUpBlock.ts b/frontend/src/pages/chat/actionBtnPopUpBlock.ts index 0e65bcb..1c12b9d 100644 --- a/frontend/src/pages/chat/actionBtnPopUpBlock.ts +++ b/frontend/src/pages/chat/actionBtnPopUpBlock.ts @@ -6,7 +6,7 @@ export function actionBtnPopUpBlock(block: ClientProfil, senderSocket: Socket) { setTimeout(() => { const blockUserBtn = document.querySelector("#popup-b-block"); blockUserBtn?.addEventListener("click", () => { - block.text = ''; + block.text = ''; blockUser(block, senderSocket); }); }, 0) diff --git a/frontend/src/pages/chat/chat.ts b/frontend/src/pages/chat/chat.ts index 1047911..e5258c9 100644 --- a/frontend/src/pages/chat/chat.ts +++ b/frontend/src/pages/chat/chat.ts @@ -261,8 +261,8 @@ async function openMessagePopup(message: string) { if (modalmessage) { const messageElement = document.createElement("div"); messageElement.innerHTML = ` -
-
Next Game Message ${incrementCounter()}: ${obj.link}
+
Next Game Message ${incrementCounter()}: ${obj}
`; modalmessage.appendChild(messageElement); modalmessage.scrollTop = modalmessage.scrollHeight; @@ -356,6 +356,7 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn profil.SenderID = getUser()?.id ?? ""; profil.SenderName = getUser()?.name ?? ""; openProfilePopup(profil); + socket.emit('isBlockdBtn', profil); console.log(`DEBUG LOG: userId:${profil.userID}: senderID${profil.SenderID}' senderID:${getUser()?.id}`); console.log(`DEBUG LOG: user:${profil.user}: sender:${profil.SenderName}' senderID:${getUser()?.name}`); socket.emit('check_Block_button', profil); @@ -375,9 +376,10 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn socket.on('blockUser', (blocked: ClientProfil) => { let icon = '⛔'; + const chatWindow = document.getElementById("t-chatbox") as HTMLDivElement; const messageElement = document.createElement("div"); - if (`${blocked.text}` === 'I have un-blocked you' ) { icon = '💚'}; + if (`${blocked.text}` === 'I have un-blocked you' ) {icon = '💚'}; messageElement.innerText =`${icon}${blocked.SenderName}: ${blocked.text}`; chatWindow.appendChild(messageElement); chatWindow.scrollTop = chatWindow.scrollHeight; @@ -418,7 +420,7 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn setTimeout(() => { connected(socket); - }, 0); + }, 16); if (window.location.pathname === '/app/chat') { console.log('%cWindow is focused on /chat:' + socket.id, color.green); if (socket.id) { diff --git a/src/chat/src/app.ts b/src/chat/src/app.ts index c0860fb..8ee238e 100644 --- a/src/chat/src/app.ts +++ b/src/chat/src/app.ts @@ -134,6 +134,7 @@ declare module 'fastify' { list: (oldUser: string, user: string) => void; updateClientName: (oldUser: string, user: string) => void; blockBtn: (data: blockedUnBlocked) => void; + isBlockdBtn: (data: blockedUnBlocked) => void; check_Block_button: (data: blockedUnBlocked) => void; }>; } @@ -189,7 +190,7 @@ async function onReady(fastify: FastifyInstance) { socket.on('message', (message: string) => { // console.info(color.blue, 'DEBUG LOG: Socket connected!', color.reset, socket.id); // console.log( color.blue, 'DEBUG LOG: Received message from client', color.reset, message); - const obj: obj = JSON.parse(message) as ClientMessage; + const obj: ClientMessage = JSON.parse(message) as ClientMessage; clientChat.set(socket.id, { user: obj.user, lastSeen: Date.now() }); // console.log(color.green, 'DEBUG LOG: Message from client', color.reset, `Sender: login name: ${obj.user} - windowID ${obj.SenderWindowID} - text message: ${obj.text}`); socket.emit('welcome', { msg: 'Welcome to the chat! : ' }); @@ -202,27 +203,6 @@ async function onReady(fastify: FastifyInstance) { list_SocketListener(fastify, socket); - - - // socket.on('list', (object) => { - - // const userFromFrontend = object || null; - // const client = clientChat.get(socket.id) || null; - - // //console.log(color.red, 'DEBUG LOG: list activated', userFromFrontend, color.reset, socket.id); - - // if (userFromFrontend.oldUser !== userFromFrontend.user) { - // //console.log(color.red, 'DEBUG LOG: list activated', userFromFrontend.oldUser, color.reset); - // // if (client?.user === null) { - // // console.log('ERROR: clientName is NULL'); - // // return; - // // }; - // if (client) { - // client.user = userFromFrontend.user; - // } - // } - // connectedUser(fastify.io, socket.id); - // }); socket.on('updateClientName', (object) => { const userFromFrontend = object || null; @@ -384,6 +364,42 @@ async function onReady(fastify: FastifyInstance) { } }); + socket.on('isBlockdBtn', async (data: ClientProfil) => { + const profilBlock: ClientProfil = data || ''; + const users: User[] = fastify.db.getAllUsers() ?? []; + const UserToBlock: User | null = getUserByName(users, `${profilBlock.user}`); + const UserAskingToBlock: User | null = getUserByName(users, `${profilBlock.SenderName}`); + + console.log(color.yellow, `user to block: ${profilBlock.user}`); + console.log(color.yellow, UserToBlock); + console.log(color.yellow, `user Asking to block: ${profilBlock.SenderName}`); + console.log(color.yellow, UserAskingToBlock); + + if (!UserAskingToBlock || !UserToBlock) return; + + if(isUser_BlockedBy_me(fastify, UserAskingToBlock!.id, UserToBlock!.id)) { + const message: blockedUnBlocked = + { + userState: "block", + userTarget: UserToBlock.name, + by: UserAskingToBlock.name, + + + }; + socket.emit('blockBtn', message); + } else { + + const message: blockedUnBlocked = + { + userState: "un-block", + userTarget: UserToBlock.name, + by: UserAskingToBlock.name, + + }; + socket.emit('blockBtn', message); + + + } }); socket.on('blockUser', async (data: string) => { @@ -393,16 +409,37 @@ async function onReady(fastify: FastifyInstance) { const UserToBlock: User | null = getUserByName(users, `${profilBlock.user}`); const UserAskingToBlock: User | null = getUserByName(users, `${profilBlock.SenderName}`); - console.log(color.yellow, `user to block: ${profilBlock.user}`); - console.log(color.yellow, UserToBlock); - console.log(color.yellow, `user Asking to block: ${profilBlock.SenderName}`); - console.log(color.yellow, UserAskingToBlock); - console.log(color.red, clientName); + // console.log(color.yellow, `user to block: ${profilBlock.user}`); + // console.log(color.yellow, UserToBlock); + // console.log(color.yellow, `user Asking to block: ${profilBlock.SenderName}`); + // console.log(color.yellow, UserAskingToBlock); + // console.log(color.red, clientName); const usersBlocked: BlockedData[] = fastify.db.getAllBlockedUsers() ?? []; if (!UserAskingToBlock || !UserToBlock || !usersBlocked) return; const userAreBlocked: boolean = isBlocked(UserAskingToBlock, UserToBlock, usersBlocked); - isUser_BlockedBy_me(fastify, UserAskingToBlock!.id, UserToBlock!.id); + if(isUser_BlockedBy_me(fastify, UserAskingToBlock!.id, UserToBlock!.id)) { + const message: blockedUnBlocked = + { + userState: "un-block", + userTarget: "", + by: "", + + }; + socket.emit('blockBtn', message); + } else { + + const message: blockedUnBlocked = + { + userState: "block", + userTarget: UserToBlock.name, + by: UserAskingToBlock.name, + + }; + socket.emit('blockBtn', message); + + + } if (userAreBlocked) { @@ -436,14 +473,14 @@ async function onReady(fastify: FastifyInstance) { } // profilBlock.Sendertext = `'You have un-blocked '`; sendBlocked(fastify, blockedMessage, profilBlock); - const message: blockedUnBlocked = - { - userState: "un-block", - userTarget: "", - by: "", + // const message: blockedUnBlocked = + // { + // userState: "un-block", + // userTarget: "", + // by: "", - }; - socket.emit('blockBtn', message); + // }; + // socket.emit('blockBtn', message); } } else { @@ -475,14 +512,14 @@ async function onReady(fastify: FastifyInstance) { // clientChat.delete(obj.user); } sendBlocked(fastify, blockedMessage, profilBlock); - const message: blockedUnBlocked = - { - userState: "block", - userTarget: UserToBlock.name, - by: UserAskingToBlock.name, + // const message: blockedUnBlocked = + // { + // userState: "block", + // userTarget: UserToBlock.name, + // by: UserAskingToBlock.name, - }; - socket.emit('blockBtn', message); + // }; + // socket.emit('blockBtn', message); } } }); From f506fb44bfe28c478c49760850ec11c239ebfe09 Mon Sep 17 00:00:00 2001 From: NigeParis Date: Wed, 17 Dec 2025 17:21:06 +0100 Subject: [PATCH 11/30] Work in progress - blocage working on it ./app 206 --- frontend/src/pages/chat/broadcastMsg.ts | 14 ++++-- frontend/src/pages/chat/chat.ts | 44 ++++++++++--------- frontend/src/pages/chat/types_front.ts | 11 ++++- src/chat/src/app.ts | 57 ++++++++++++++++++++++--- src/chat/src/broadcast.ts | 3 ++ src/chat/src/chat_types.ts | 14 +++++- src/chat/src/color.ts | 8 ++++ src/chat/src/filter_Blocked_user.ts | 39 +++++++++++++++++ src/chat/src/getUserById.ts | 10 +++++ src/chat/src/isUser_BlockedBy_me.ts | 32 ++++++++++++++ src/chat/src/routes/broadcast.ts | 2 +- 11 files changed, 201 insertions(+), 33 deletions(-) create mode 100644 src/chat/src/color.ts create mode 100644 src/chat/src/filter_Blocked_user.ts create mode 100644 src/chat/src/getUserById.ts create mode 100644 src/chat/src/isUser_BlockedBy_me.ts diff --git a/frontend/src/pages/chat/broadcastMsg.ts b/frontend/src/pages/chat/broadcastMsg.ts index 51a1130..586243b 100644 --- a/frontend/src/pages/chat/broadcastMsg.ts +++ b/frontend/src/pages/chat/broadcastMsg.ts @@ -1,7 +1,7 @@ import { addMessage } from "./addMessage"; import { Socket } from 'socket.io-client'; import { getUser } from "@app/auth"; - +import type { ClientMessage } from "./types_front"; /** * function sends socket.emit to the backend to active and broadcast a message to all sockets * echos the message with addMessage to the sender @@ -13,15 +13,21 @@ export function broadcastMsg (socket: Socket, msgCommand: string[]): void { addMessage(msgText); const user = getUser(); if (user && socket?.connected) { - const message = { - command: msgCommand, + const message: ClientMessage = { + command: msgCommand[0], destination: '', type: "chat", user: user.name, token: document.cookie, text: msgText, timestamp: Date.now(), - SenderWindowID: socket.id, + SenderWindowID: socket.id ?? "", + SenderUserName: user.name, + SenderUserID: user.id, + userID: '', + frontendUserName: '', + frontendUser: '', + Sendertext: '', }; socket.emit('message', JSON.stringify(message)); } diff --git a/frontend/src/pages/chat/chat.ts b/frontend/src/pages/chat/chat.ts index e5258c9..a35ea5d 100644 --- a/frontend/src/pages/chat/chat.ts +++ b/frontend/src/pages/chat/chat.ts @@ -193,6 +193,7 @@ function logout(socket: Socket) { async function connected(socket: Socket): Promise { + setTimeout(async () => { try { const buddies = document.getElementById('div-buddies') as HTMLDivElement; const loggedIn = isLoggedIn(); @@ -201,24 +202,23 @@ async function connected(socket: Socket): Promise { let oldUser = localStorage.getItem("oldName") ?? ""; console.log('%coldUser:',color.yellow, oldUser); if (loggedIn?.name === undefined) {console.log('');return ;} - setTimeout(() => { oldUser = loggedIn.name ?? ""; - }, 0); - // const res = await client.guestLogin(); - let user = await updateUser(); - console.log('%cUser?name:',color.yellow, user?.name); - localStorage.setItem("oldName", oldUser); - buddies.textContent = ""; - socket.emit('list', { - oldUser: oldUser, - user: user?.name, - }); - } catch (e) { - console.error("Login error:", e); - showError('Failed to login: Unknown error'); - } -}; - + // const res = await client.guestLogin(); + let user = await updateUser(); + console.log('%cUser?name:',color.yellow, user?.name); + localStorage.setItem("oldName", oldUser); + buddies.textContent = ""; + socket.emit('list', { + oldUser: oldUser, + user: user?.name, + }); + } catch (e) { + console.error("Login error:", e); + showError('Failed to login: Unknown error'); + } + }, 16); + }; + async function whoami(socket: Socket) { try { const chatWindow = document.getElementById("t-chatbox") as HTMLDivElement; @@ -281,6 +281,8 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn let socket = getSocket(); + let blockMessage: boolean; + setTimeout(async () => { // Listen for the 'connect' event socket.on("connect", async () => { @@ -310,6 +312,7 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn systemWindow.appendChild(messageElement); systemWindow.scrollTop = systemWindow.scrollHeight; }); +}, 0); // Listen for messages from the server "MsgObjectServer" socket.on("MsgObjectServer", (data: { message: ClientMessage}) => { @@ -321,8 +324,8 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn if (bconnected) { connected(socket); } - - if (chatWindow && data.message.destination === "") { + console.log('stahe eeee :', blockMessage); + if (chatWindow && data.message.destination === "" && !blockMessage) { const messageElement = document.createElement("div"); messageElement.textContent = `${data.message.user}: ${data.message.text}`; chatWindow.appendChild(messageElement); @@ -394,7 +397,7 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn console.log(' =================== >>> UserTarget:', data.userTarget); console.log(' =================== >>> By:', data.by); let message = ""; - if (data.userState === "block") {message = "un-block"} else{message = "block"} + if (data.userState === "block") {message = "un-block", blockMessage = true} else{message = "block", blockMessage = false} blockUserBtn.textContent = message; } }); @@ -587,5 +590,6 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn }); } } + }; addRoute('/chat', handleChat, { bypass_auth: true }); diff --git a/frontend/src/pages/chat/types_front.ts b/frontend/src/pages/chat/types_front.ts index 913095a..93f9ab6 100644 --- a/frontend/src/pages/chat/types_front.ts +++ b/frontend/src/pages/chat/types_front.ts @@ -1,9 +1,18 @@ export type ClientMessage = { command: string destination: string; + type: string, user: string; + userID: string, + token: string + frontendUserName: string, + frontendUser: string, text: string; - SenderWindowID: string; + SenderWindowID: string, + SenderUserName: string, + SenderUserID: string, + timestamp: number, + Sendertext: string, }; diff --git a/src/chat/src/app.ts b/src/chat/src/app.ts index 8ee238e..fac6cb4 100644 --- a/src/chat/src/app.ts +++ b/src/chat/src/app.ts @@ -20,6 +20,7 @@ import { sendProfil } from './sendProfil'; import { setGameLink } from './setGameLink'; import { nextGame_SocketListener } from './nextGame_SocketListener'; import { list_SocketListener } from './list_SocketListener'; +import { filter_Blocked_user } from './filter_Blocked_user' // colors for console.log export const color = { @@ -196,6 +197,37 @@ async function onReady(fastify: FastifyInstance) { socket.emit('welcome', { msg: 'Welcome to the chat! : ' }); // Send object directly — DO NOT wrap it in a string broadcast(fastify, obj, obj.SenderWindowID); + + const users: User[] = fastify.db.getAllUsers() ?? []; + console.log('DEBUG: senderWindow :', getUserById(users, obj.SenderUserID)?.name); + + + + + fastify.io.fetchSockets().then((sockets) => { + for (const socket of sockets) { + const clientInfo = clientChat.get(socket.id); + if (!clientInfo?.user) { + console.log(color.yellow, `Skipping socket ${socket.id} (no user found)`); + continue; + } + console.log('DEBUG: UserIDWindow :', getUserByName(users, clientInfo.user)?.id); + const IDUser = getUserByName(users, clientInfo.user)?.id; + + console.log(filter_Blocked_user(fastify, obj, IDUser?? "")); + + + } + }); + + + + + + + + + // console.log(color.red, 'DEBUG LOG: connected in the Chat :', connectedUser(fastify.io), color.reset); }); @@ -227,7 +259,7 @@ async function onReady(fastify: FastifyInstance) { if (!clientName) return; console.log(color.green, `Client logging out: ${clientName} (${socket.id})`); - const obj: obj = { + const obj: ClientMessage = { command: '', destination: 'system-info', type: 'chat' as const, @@ -239,6 +271,9 @@ async function onReady(fastify: FastifyInstance) { timestamp: Date.now(), SenderWindowID: socket.id, Sendertext: '', + userID: '', + SenderUserName: '', + SenderUserID: '', }; broadcast(fastify, obj, socket.id); // Optional: remove from map @@ -257,7 +292,7 @@ async function onReady(fastify: FastifyInstance) { if (reason === 'transport error') return; if (clientName !== null) { - const obj: obj = { + const obj: ClientMessage = { command: '', destination: 'system-info', type: 'chat', @@ -269,6 +304,9 @@ async function onReady(fastify: FastifyInstance) { timestamp: Date.now(), SenderWindowID: socket.id, Sendertext: '', + userID: '', + SenderUserName: '', + SenderUserID: '', }; broadcast(fastify, obj, obj.SenderWindowID); @@ -285,7 +323,7 @@ async function onReady(fastify: FastifyInstance) { ); if (clientName !== null) { - const obj: obj = { + const obj: ClientMessage = { command: '', destination: 'system-info', type: 'chat', @@ -297,6 +335,9 @@ async function onReady(fastify: FastifyInstance) { timestamp: Date.now(), SenderWindowID: socket.id, Sendertext: '', + userID: '', + SenderUserName: '', + SenderUserID: '', }; // console.log(color.blue, 'DEBUG LOG: BROADCASTS OUT :', obj.SenderWindowID); @@ -316,7 +357,7 @@ async function onReady(fastify: FastifyInstance) { ); if (clientName !== null) { - const obj: obj = { + const obj: ClientMessage = { command: prvMessage.command, destination: 'privateMsg', type: 'chat', @@ -328,6 +369,9 @@ async function onReady(fastify: FastifyInstance) { timestamp: Date.now(), SenderWindowID: socket.id, Sendertext: '', + userID: '', + SenderUserName: '', + SenderUserID:'', }; // console.log(color.blue, 'DEBUG LOG: PRIV MESSAGE OUT :', obj.SenderWindowID); sendPrivMessage(fastify, obj, obj.SenderWindowID); @@ -553,7 +597,7 @@ async function onReady(fastify: FastifyInstance) { `Client entered the Chat: ${clientName} (${socket.id})`, ); if (clientName !== null) { - const obj: obj = { + const obj: ClientMessage = { command: '', destination: 'system-info', type: 'chat', @@ -565,6 +609,9 @@ async function onReady(fastify: FastifyInstance) { timestamp: Date.now(), SenderWindowID: socket.id, Sendertext: "", + userID: '', + SenderUserName: '', + SenderUserID: '', }; broadcast(fastify, obj, obj.SenderWindowID); } diff --git a/src/chat/src/broadcast.ts b/src/chat/src/broadcast.ts index 1d697fa..e028d7d 100644 --- a/src/chat/src/broadcast.ts +++ b/src/chat/src/broadcast.ts @@ -1,6 +1,7 @@ import type { ClientMessage } from './chat_types'; import { clientChat, color } from './app'; import { FastifyInstance } from 'fastify'; +import { getUserById } from './getUserById'; export function broadcast(fastify: FastifyInstance, data: ClientMessage, sender?: string) { fastify.io.fetchSockets().then((sockets) => { @@ -13,6 +14,8 @@ export function broadcast(fastify: FastifyInstance, data: ClientMessage, sender? console.log(color.yellow, `Skipping socket ${socket.id} (no user found)`); continue; } + // console.log('BLOCKED MAYBE', getUserById(sender)); + // console.log('TARGET',socket.id ); // Emit structured JSON object socket.emit('MsgObjectServer', { message: data }); // Debug logs diff --git a/src/chat/src/chat_types.ts b/src/chat/src/chat_types.ts index 0377659..05a938e 100644 --- a/src/chat/src/chat_types.ts +++ b/src/chat/src/chat_types.ts @@ -1,11 +1,21 @@ export type ClientMessage = { command: string destination: string; + type: string, user: string; + userID: string, + token: string + frontendUserName: string, + frontendUser: string, text: string; - SenderWindowID: string; + SenderWindowID: string, + SenderUserName: string, + SenderUserID: string, + timestamp: number, + Sendertext: string, }; + export type ClientProfil = { command: string, destination: string, @@ -21,4 +31,4 @@ export type ClientProfil = { Sendertext: string, innerHtml?: string, -}; \ No newline at end of file +}; diff --git a/src/chat/src/color.ts b/src/chat/src/color.ts new file mode 100644 index 0000000..cb87c2c --- /dev/null +++ b/src/chat/src/color.ts @@ -0,0 +1,8 @@ +// colors for console.log +export const color = { + red: '\x1b[31m', + green: '\x1b[32m', + yellow: '\x1b[33m', + blue: '\x1b[34m', + reset: '\x1b[0m', +}; \ No newline at end of file diff --git a/src/chat/src/filter_Blocked_user.ts b/src/chat/src/filter_Blocked_user.ts new file mode 100644 index 0000000..3f96bef --- /dev/null +++ b/src/chat/src/filter_Blocked_user.ts @@ -0,0 +1,39 @@ +import type { ClientMessage, ClientProfil } from './chat_types'; +import { FastifyInstance } from 'fastify'; +import type { User } from '@shared/database/mixin/user'; +import { getUserById } from './getUserById'; +import { isUser_BlockedBy_me } from './isUser_BlockedBy_me'; + +/** + * function to check if blocked or not - checks with ID + * @param fastify + * @param data + * @returns true or false - true if blocked user by a user + */ + +export function filter_Blocked_user(fastify: FastifyInstance, data: ClientMessage, id: string): boolean { + + const users: User[] = fastify.db.getAllUsers() ?? []; + const UserToBlock: string = id; + const UserAskingToBlock: User | null = getUserById(users,`${data.SenderUserID}`); + if (!UserAskingToBlock ) { + // console.log('SOMETHING NULL', data); + // console.log('UsetToBlock', UserToBlock?.id); + // console.log('UsetToBlock', UserToBlock?.name); + // console.log('UsetAskingToBlock', UserAskingToBlock?.id); + // console.log('UsetAskingToBlock', UserAskingToBlock?.name); + console.log(''); + + + return false; + } + if(isUser_BlockedBy_me(fastify, UserAskingToBlock!.id, UserToBlock)) + { + return true; + } + else + { + return false; + } +} + diff --git a/src/chat/src/getUserById.ts b/src/chat/src/getUserById.ts new file mode 100644 index 0000000..a276238 --- /dev/null +++ b/src/chat/src/getUserById.ts @@ -0,0 +1,10 @@ +import type { User } from '@shared/database/mixin/user'; +/** + * function get the object user in an array of users[] by name + * @param users + * @param name + * @returns + */ +export function getUserById(users: User[], id: string) { + return users.find(user => user.id === id) || null; +}; diff --git a/src/chat/src/isUser_BlockedBy_me.ts b/src/chat/src/isUser_BlockedBy_me.ts new file mode 100644 index 0000000..dcd7bb4 --- /dev/null +++ b/src/chat/src/isUser_BlockedBy_me.ts @@ -0,0 +1,32 @@ +import { FastifyInstance } from 'fastify'; +import type { User } from '@shared/database/mixin/user'; +import type { BlockedData } from '@shared/database/mixin/blocked'; +import { isBlocked } from './isBlocked'; +import { getUserById } from './getUserById'; +import { color } from './color'; + +/** + * checks the Db for the two matching Ids + * @param fastify + * @param blockedBy_Id + * @param isBlocked_Id + * @returns Null if not blocked + */ + +export function isUser_BlockedBy_me(fastify: FastifyInstance, blockedBy_Id : string, isBlocked_Id: string): string { + const users: User[] = fastify.db.getAllUsers() ?? []; + if (!users) return ''; + const UserToBlock: User | null = getUserById(users, `${isBlocked_Id}`); + const UserAskingToBlock: User | null = getUserById(users, `${blockedBy_Id}`); + if (!UserToBlock) {console.log(color.blue, `'User: ${UserAskingToBlock?.id} has not blocked' ${isBlocked_Id}`); return ""}; + if (!UserAskingToBlock) {console.log(color.blue, `'User: ${UserToBlock?.id} has not blocked by' ${blockedBy_Id}`); return ""}; + const usersBlocked: BlockedData[] = fastify.db.getAllBlockedUsers() ?? []; + const userAreBlocked: boolean = isBlocked(UserAskingToBlock, UserToBlock, usersBlocked); + if (userAreBlocked) { + console.log(color.yellow, `'User :${UserAskingToBlock.name}) Hhas UN blocked ${UserToBlock.name}`) + return UserAskingToBlock.name; + } + console.log(color.blue, `'User :${UserAskingToBlock.name}) has BBBblocked ${UserToBlock.name}`) + + return ""; +}; diff --git a/src/chat/src/routes/broadcast.ts b/src/chat/src/routes/broadcast.ts index 9bd0ec2..de46038 100644 --- a/src/chat/src/routes/broadcast.ts +++ b/src/chat/src/routes/broadcast.ts @@ -19,7 +19,7 @@ const route: FastifyPluginAsync = async (fastify): Promise => { config: { requireAuth: false }, }, async function(req, res) { - broadcast(this, { command: '', destination: '', user: 'CMwaLeSever!!', text: req.body.message, SenderWindowID: 'server' }); + //broadcast(this, { command: '', destination: '', user: 'CMwaLeSever!!', text: req.body.message, SenderWindowID: 'server' }); void res; }, ); From a7fcb351f80d0828e69cc639c82c817477ccf239 Mon Sep 17 00:00:00 2001 From: NigeParis Date: Thu, 18 Dec 2025 20:03:24 +0100 Subject: [PATCH 12/30] WIP trying to fix a bug with blocking Broadcast message from a user on the chat --- frontend/src/pages/chat/chat.ts | 31 +++---------- frontend/src/pages/chat/types_front.ts | 18 +++++++- src/chat/src/app.ts | 60 ++++++------------------ src/chat/src/broadcast.ts | 63 ++++++++++++++++++++++++-- src/chat/src/chat_types.ts | 16 +++++++ src/chat/src/makeProfil.ts | 1 + 6 files changed, 115 insertions(+), 74 deletions(-) diff --git a/frontend/src/pages/chat/chat.ts b/frontend/src/pages/chat/chat.ts index a35ea5d..2998eef 100644 --- a/frontend/src/pages/chat/chat.ts +++ b/frontend/src/pages/chat/chat.ts @@ -9,7 +9,7 @@ import { getProfil } from './getProfil'; import { addMessage } from './addMessage'; import { broadcastMsg } from './broadcastMsg'; import { isLoggedIn } from './isLoggedIn'; -import type { ClientMessage, ClientProfil } from './types_front'; +import type { ClientMessage, ClientProfil, obj } from './types_front'; import { openProfilePopup } from './openProfilePopup'; import { actionBtnPopUpClear } from './actionBtnPopUpClear'; import { actionBtnPopUpBlock } from './actionBtnPopUpBlock'; @@ -31,20 +31,6 @@ export type blockedUnBlocked = by: string, }; -export type obj = -{ - command: string, - destination: string, - type: string, - user: string, - frontendUserName: string, - frontendUser: string, - token: string, - text: string, - timestamp: number, - SenderWindowID: string, - Sendertext: string, -}; // get the name of the machine used to connect const machineHostName = window.location.hostname; @@ -176,11 +162,6 @@ function quitChat (socket: Socket) { }; -// const bconnected = document.getElementById('b-help') as HTMLButtonElement; -// if (bconnected) { -// bconnected.click(); -// } - function logout(socket: Socket) { socket.emit("logout"); // notify server socket.disconnect(); // actually close the socket @@ -321,6 +302,11 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn const chatWindow = document.getElementById("t-chatbox") as HTMLDivElement; const bconnected = document.getElementById('b-help') as HTMLButtonElement; + console.log('UserSender:', data.message.SenderUserID); + console.log('User:', getUser()?.id); + + + if (bconnected) { connected(socket); } @@ -419,7 +405,6 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn let toggle = false window.addEventListener("focus", async () => { - //nst bwhoami = document.getElementById('b-whoami') as HTMLButtonElement; setTimeout(() => { connected(socket); @@ -440,10 +425,6 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn toggle = false; }); - // setInterval(async () => { - // //connected(socket); - // },10000); // every 10 sec - socket.on('listBud', async (myBuddies: string[]) => { const buddies = document.getElementById('div-buddies') as HTMLDivElement; console.log('%cList buddies connected ',color.yellow, myBuddies); diff --git a/frontend/src/pages/chat/types_front.ts b/frontend/src/pages/chat/types_front.ts index 93f9ab6..33206d4 100644 --- a/frontend/src/pages/chat/types_front.ts +++ b/frontend/src/pages/chat/types_front.ts @@ -30,4 +30,20 @@ export type ClientProfil = { SenderID: string, Sendertext: string, innerHtml?: string, -}; \ No newline at end of file +}; + + +export type obj = +{ + command: string, + destination: string, + type: string, + user: string, + frontendUserName: string, + frontendUser: string, + token: string, + text: string, + timestamp: number, + SenderWindowID: string, + Sendertext: string, +}; diff --git a/src/chat/src/app.ts b/src/chat/src/app.ts index fac6cb4..7e8e10f 100644 --- a/src/chat/src/app.ts +++ b/src/chat/src/app.ts @@ -9,7 +9,7 @@ import { Server, Socket } from 'socket.io'; import type { User } from '@shared/database/mixin/user'; import type { BlockedData } from '@shared/database/mixin/blocked'; import { broadcast } from './broadcast'; -import type { ClientProfil, ClientMessage } from './chat_types'; +import type { ClientProfil, ClientMessage, obj } from './chat_types'; import { sendPrivMessage } from './sendPrivMessage'; import { sendBlocked } from './sendBlocked'; import { sendInvite } from './sendInvite'; @@ -37,6 +37,7 @@ declare const __SERVICE_NAME: string; // key = socket, value = clientname interface ClientInfo { user: string; + socket: string lastSeen: number; } @@ -49,37 +50,6 @@ export type blockedUnBlocked = }; -export type obj = -{ - command: string, - destination: string, - type: string, - user: string, - frontendUserName: string, - frontendUser: string, - token: string, - text: string, - timestamp: number, - SenderWindowID: string, - Sendertext: string, -}; - - - -// function setAboutPlayer(about: string): string { -// if (!about) { -// about = 'Player is good Shape - This is a default description'; -// } -// return about; -// }; - -// function setGameLink(link: string): string { -// if (!link) { -// link = 'Click me'; -// } -// return link; -// }; - export const clientChat = new Map(); // @ts-expect-error: import.meta.glob is a vite thing. Typescript doesn't know this... @@ -192,7 +162,7 @@ async function onReady(fastify: FastifyInstance) { // console.info(color.blue, 'DEBUG LOG: Socket connected!', color.reset, socket.id); // console.log( color.blue, 'DEBUG LOG: Received message from client', color.reset, message); const obj: ClientMessage = JSON.parse(message) as ClientMessage; - clientChat.set(socket.id, { user: obj.user, lastSeen: Date.now() }); + clientChat.set(socket.id, { user: obj.user, socket: socket.id, lastSeen: Date.now() }); // console.log(color.green, 'DEBUG LOG: Message from client', color.reset, `Sender: login name: ${obj.user} - windowID ${obj.SenderWindowID} - text message: ${obj.text}`); socket.emit('welcome', { msg: 'Welcome to the chat! : ' }); // Send object directly — DO NOT wrap it in a string @@ -204,21 +174,21 @@ async function onReady(fastify: FastifyInstance) { - fastify.io.fetchSockets().then((sockets) => { - for (const socket of sockets) { - const clientInfo = clientChat.get(socket.id); - if (!clientInfo?.user) { - console.log(color.yellow, `Skipping socket ${socket.id} (no user found)`); - continue; - } - console.log('DEBUG: UserIDWindow :', getUserByName(users, clientInfo.user)?.id); - const IDUser = getUserByName(users, clientInfo.user)?.id; + // fastify.io.fetchSockets().then((sockets) => { + // for (const socket of sockets) { + // const clientInfo = clientChat.get(socket.id); + // if (!clientInfo?.user) { + // console.log(color.yellow, `Skipping socket ${socket.id} (no user found)`); + // continue; + // } + // console.log('DEBUG: UserIDWindow :', getUserByName(users, clientInfo.user)?.id); + // const IDUser = getUserByName(users, clientInfo.user)?.id; - console.log(filter_Blocked_user(fastify, obj, IDUser?? "")); + // console.log(filter_Blocked_user(fastify, obj, IDUser?? "")); - } - }); + // } + // }); diff --git a/src/chat/src/broadcast.ts b/src/chat/src/broadcast.ts index e028d7d..50fd98b 100644 --- a/src/chat/src/broadcast.ts +++ b/src/chat/src/broadcast.ts @@ -1,23 +1,80 @@ import type { ClientMessage } from './chat_types'; import { clientChat, color } from './app'; import { FastifyInstance } from 'fastify'; -import { getUserById } from './getUserById'; +import type { BlockedData } from '@shared/database/mixin/blocked'; +import { getUserByName } from './getUserByName'; +import type { User } from '@shared/database/mixin/user'; + + + +type BlockRelation = { + blocked: string; + blocker: string; +}; + +function whoBlockedMe( + fastify: FastifyInstance, + myName: string +):BlockRelation [] { + const usersBlocked = + fastify.db.getAllBlockedUsers() ?? []; + + return usersBlocked + .filter(entry => entry.blocked === myName) + .map(entry => ({ + blocked: entry.user, + blocker: entry.blocked, + })); +} + + + + export function broadcast(fastify: FastifyInstance, data: ClientMessage, sender?: string) { + + const AllusersBlocked: User[] = fastify.db.getAllUsers() ?? []; + //console.log(color.yellow, 'me:', getUserByName(AllusersBlocked, data.user)?.id) + const UserByName = getUserByName(AllusersBlocked, data.user)?.id ?? ""; + const list:BlockRelation[] = whoBlockedMe(fastify, UserByName); + const blockers = list.map(r => r.blocker); +const blocked = list.map(r => r.blocked); +console.log('All blockers:', blockers); +console.log('All blocked:', blocked); + //console.log(color.yellow, 'list:', list) fastify.io.fetchSockets().then((sockets) => { for (const socket of sockets) { // Skip sender's own socket - if (socket.id === sender) continue; + //if (socket.id === sender) continue; // Get client name from map const clientInfo = clientChat.get(socket.id); if (!clientInfo?.user) { - console.log(color.yellow, `Skipping socket ${socket.id} (no user found)`); + //console.log(color.yellow, `Skipping socket ${socket.id} (no user found)`); continue; } // console.log('BLOCKED MAYBE', getUserById(sender)); // console.log('TARGET',socket.id ); // Emit structured JSON object + + const UserByName = getUserByName(AllusersBlocked, data.user)?.name ?? ""; + const UserByID = getUserByName(AllusersBlocked, data.user)?.id ?? ""; + //console.log(color.blue, 'Asking:', UserByName); + //console.log(color.blue, 'Asking ID:', UserByID); + + console.log('Blocked list:', list); + //console.log('Sender ID:', UserByID); + + // if (!list.includes(UserByID)) { + // console.log('TRUE → sender NOT blocked'); + // } else { + // console.log('FALSE → sender IS blocked'); + // } + if (list.filter(entry => entry.blocker === UserByID)) continue; socket.emit('MsgObjectServer', { message: data }); + + + + // Debug logs // console.log(color.green, `'DEBUG LOG: Broadcast to:', ${data.command} message: ${data.text}`); } diff --git a/src/chat/src/chat_types.ts b/src/chat/src/chat_types.ts index 05a938e..ae26cbc 100644 --- a/src/chat/src/chat_types.ts +++ b/src/chat/src/chat_types.ts @@ -32,3 +32,19 @@ export type ClientProfil = { innerHtml?: string, }; + + +export type obj = +{ + command: string, + destination: string, + type: string, + user: string, + frontendUserName: string, + frontendUser: string, + token: string, + text: string, + timestamp: number, + SenderWindowID: string, + Sendertext: string, +}; diff --git a/src/chat/src/makeProfil.ts b/src/chat/src/makeProfil.ts index 08d45e8..25d4b15 100644 --- a/src/chat/src/makeProfil.ts +++ b/src/chat/src/makeProfil.ts @@ -35,6 +35,7 @@ export async function makeProfil(fastify: FastifyInstance, user: string, socket: SenderWindowID: socket.id, SenderName: '', Sendertext: '', + SenderID: '', innerHtml: '', }; } From 73a41f2b3956fdcdc20f827af5bc82572bb178e3 Mon Sep 17 00:00:00 2001 From: NigeParis Date: Thu, 18 Dec 2025 20:09:57 +0100 Subject: [PATCH 13/30] Conflits merge --- frontend/src/pages/chat/chat.ts | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/frontend/src/pages/chat/chat.ts b/frontend/src/pages/chat/chat.ts index 7d79aab..2998eef 100644 --- a/frontend/src/pages/chat/chat.ts +++ b/frontend/src/pages/chat/chat.ts @@ -31,23 +31,6 @@ export type blockedUnBlocked = by: string, }; -<<<<<<< HEAD -======= -export type obj = -{ - command: string, - destination: string, - type: string, - user: string, - frontendUserName: string, - frontendUser: string, - token: string, - text: string, - timestamp: number, - SenderWindowID: string, - Sendertext: string, -}; ->>>>>>> refs/remotes/origin/nigel/functionBlockMessage // get the name of the machine used to connect const machineHostName = window.location.hostname; From 46a1b99ed14e693dc8edc77c2aa00218a05666bc Mon Sep 17 00:00:00 2001 From: NigeParis Date: Thu, 18 Dec 2025 20:18:45 +0100 Subject: [PATCH 14/30] Merge conflicts --- frontend/src/pages/chat/chat.ts | 1 - src/chat/src/app.ts | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/pages/chat/chat.ts b/frontend/src/pages/chat/chat.ts index 2998eef..a1070bf 100644 --- a/frontend/src/pages/chat/chat.ts +++ b/frontend/src/pages/chat/chat.ts @@ -31,7 +31,6 @@ export type blockedUnBlocked = by: string, }; - // get the name of the machine used to connect const machineHostName = window.location.hostname; console.log('connect to login at %chttps://' + machineHostName + ':8888/app/login',color.yellow); diff --git a/src/chat/src/app.ts b/src/chat/src/app.ts index 7e8e10f..75aebf2 100644 --- a/src/chat/src/app.ts +++ b/src/chat/src/app.ts @@ -388,6 +388,7 @@ async function onReady(fastify: FastifyInstance) { console.log(color.yellow, UserToBlock); console.log(color.yellow, `user Asking to block: ${profilBlock.SenderName}`); console.log(color.yellow, UserAskingToBlock); + console.log(color.red, clientName); if (!UserAskingToBlock || !UserToBlock) return; From 8bfa65ba51675ecf0c4b04815ce2af60833a2d3a Mon Sep 17 00:00:00 2001 From: NigeParis Date: Thu, 18 Dec 2025 20:20:04 +0100 Subject: [PATCH 15/30] Merge conflicts --- frontend/src/pages/chat/chat.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/frontend/src/pages/chat/chat.ts b/frontend/src/pages/chat/chat.ts index a1070bf..02d0b16 100644 --- a/frontend/src/pages/chat/chat.ts +++ b/frontend/src/pages/chat/chat.ts @@ -31,6 +31,21 @@ export type blockedUnBlocked = by: string, }; +export type obj = +{ + command: string, + destination: string, + type: string, + user: string, + frontendUserName: string, + frontendUser: string, + token: string, + text: string, + timestamp: number, + SenderWindowID: string, + Sendertext: string, +}; + // get the name of the machine used to connect const machineHostName = window.location.hostname; console.log('connect to login at %chttps://' + machineHostName + ':8888/app/login',color.yellow); From fd1ec359d2652d041944293f111c6645053f92de Mon Sep 17 00:00:00 2001 From: NigeParis Date: Thu, 18 Dec 2025 20:20:40 +0100 Subject: [PATCH 16/30] Merge conflicts --- src/chat/src/app.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/chat/src/app.ts b/src/chat/src/app.ts index 75aebf2..f40f88e 100644 --- a/src/chat/src/app.ts +++ b/src/chat/src/app.ts @@ -384,11 +384,11 @@ async function onReady(fastify: FastifyInstance) { const UserToBlock: User | null = getUserByName(users, `${profilBlock.user}`); const UserAskingToBlock: User | null = getUserByName(users, `${profilBlock.SenderName}`); - console.log(color.yellow, `user to block: ${profilBlock.user}`); - console.log(color.yellow, UserToBlock); - console.log(color.yellow, `user Asking to block: ${profilBlock.SenderName}`); - console.log(color.yellow, UserAskingToBlock); - console.log(color.red, clientName); + // console.log(color.yellow, `user to block: ${profilBlock.user}`); + // console.log(color.yellow, UserToBlock); + // console.log(color.yellow, `user Asking to block: ${profilBlock.SenderName}`); + // console.log(color.yellow, UserAskingToBlock); + // console.log(color.red, clientName); if (!UserAskingToBlock || !UserToBlock) return; From 384e0b62563a1ef813f1e969769a600254c1d59d Mon Sep 17 00:00:00 2001 From: NigeParis Date: Thu, 18 Dec 2025 20:24:39 +0100 Subject: [PATCH 17/30] WIP conflits sorted out --- frontend/src/pages/chat/chat.ts | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/frontend/src/pages/chat/chat.ts b/frontend/src/pages/chat/chat.ts index 02d0b16..2998eef 100644 --- a/frontend/src/pages/chat/chat.ts +++ b/frontend/src/pages/chat/chat.ts @@ -31,20 +31,6 @@ export type blockedUnBlocked = by: string, }; -export type obj = -{ - command: string, - destination: string, - type: string, - user: string, - frontendUserName: string, - frontendUser: string, - token: string, - text: string, - timestamp: number, - SenderWindowID: string, - Sendertext: string, -}; // get the name of the machine used to connect const machineHostName = window.location.hostname; From d9cc54ade91811e933c1f5be141bb4ac24157b2a Mon Sep 17 00:00:00 2001 From: NigeParis Date: Thu, 18 Dec 2025 20:26:00 +0100 Subject: [PATCH 18/30] WIP conflits sorted out --- src/chat/src/chat_types.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/chat/src/chat_types.ts b/src/chat/src/chat_types.ts index d7306cd..ae26cbc 100644 --- a/src/chat/src/chat_types.ts +++ b/src/chat/src/chat_types.ts @@ -32,7 +32,6 @@ export type ClientProfil = { innerHtml?: string, }; -<<<<<<< HEAD export type obj = @@ -49,5 +48,3 @@ export type obj = SenderWindowID: string, Sendertext: string, }; -======= ->>>>>>> refs/remotes/origin/nigel/functionBlockMessage From 0128ec5f69fc0276829162375f703a650a3b7c36 Mon Sep 17 00:00:00 2001 From: NigeParis Date: Thu, 18 Dec 2025 20:28:13 +0100 Subject: [PATCH 19/30] Conflicts --- src/chat/src/app.ts | 53 --------------------------------------- src/chat/src/broadcast.ts | 4 --- 2 files changed, 57 deletions(-) diff --git a/src/chat/src/app.ts b/src/chat/src/app.ts index 6fc2cac..f40f88e 100644 --- a/src/chat/src/app.ts +++ b/src/chat/src/app.ts @@ -41,41 +41,6 @@ interface ClientInfo { lastSeen: number; } -<<<<<<< HEAD -======= - -export type blockedUnBlocked = -{ - userState: string, - userTarget: string, - by: string, -}; - - -export type obj = -{ - command: string, - destination: string, - type: string, - user: string, - frontendUserName: string, - frontendUser: string, - token: string, - text: string, - timestamp: number, - SenderWindowID: string, - Sendertext: string, -}; - - - -// function setAboutPlayer(about: string): string { -// if (!about) { -// about = 'Player is good Shape - This is a default description'; -// } -// return about; -// }; ->>>>>>> refs/remotes/origin/nigel/functionBlockMessage export type blockedUnBlocked = { @@ -209,7 +174,6 @@ async function onReady(fastify: FastifyInstance) { -<<<<<<< HEAD // fastify.io.fetchSockets().then((sockets) => { // for (const socket of sockets) { // const clientInfo = clientChat.get(socket.id); @@ -225,23 +189,6 @@ async function onReady(fastify: FastifyInstance) { // } // }); -======= - fastify.io.fetchSockets().then((sockets) => { - for (const socket of sockets) { - const clientInfo = clientChat.get(socket.id); - if (!clientInfo?.user) { - console.log(color.yellow, `Skipping socket ${socket.id} (no user found)`); - continue; - } - console.log('DEBUG: UserIDWindow :', getUserByName(users, clientInfo.user)?.id); - const IDUser = getUserByName(users, clientInfo.user)?.id; - - console.log(filter_Blocked_user(fastify, obj, IDUser?? "")); - - - } - }); ->>>>>>> refs/remotes/origin/nigel/functionBlockMessage diff --git a/src/chat/src/broadcast.ts b/src/chat/src/broadcast.ts index 02db5c2..50fd98b 100644 --- a/src/chat/src/broadcast.ts +++ b/src/chat/src/broadcast.ts @@ -1,7 +1,6 @@ import type { ClientMessage } from './chat_types'; import { clientChat, color } from './app'; import { FastifyInstance } from 'fastify'; -<<<<<<< HEAD import type { BlockedData } from '@shared/database/mixin/blocked'; import { getUserByName } from './getUserByName'; import type { User } from '@shared/database/mixin/user'; @@ -31,9 +30,6 @@ function whoBlockedMe( -======= -import { getUserById } from './getUserById'; ->>>>>>> refs/remotes/origin/nigel/functionBlockMessage export function broadcast(fastify: FastifyInstance, data: ClientMessage, sender?: string) { From 7c6de16becbf0d96655b17ce3b9cc2912eaded17 Mon Sep 17 00:00:00 2001 From: NigeParis Date: Thu, 18 Dec 2025 20:30:41 +0100 Subject: [PATCH 20/30] Conflicts --- src/user/src/run.ts | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/user/src/run.ts b/src/user/src/run.ts index f9dd40a..3c59d5d 100644 --- a/src/user/src/run.ts +++ b/src/user/src/run.ts @@ -4,25 +4,7 @@ import fastify, { FastifyInstance } from 'fastify'; import app from './app'; const start = async () => { -<<<<<<< HEAD const f: FastifyInstance = fastify({ logger: { level: 'info' } }); -======= - const envToLogger = { - development: { - transport: { - target: 'pino-pretty', - options: { - translateTime: 'HH:MM:ss Z', - ignore: 'pid,hostname', - }, - }, - }, - production: true, - test: false, - }; - - const f: FastifyInstance = fastify({ logger: envToLogger.development }); ->>>>>>> refs/remotes/origin/nigel/functionBlockMessage process.on('SIGTERM', () => { f.log.warn('Requested to shutdown'); process.exit(134); From 9122194b7ba670186e1d38a604c167948cfd1ca0 Mon Sep 17 00:00:00 2001 From: NigeParis Date: Thu, 18 Dec 2025 20:31:23 +0100 Subject: [PATCH 21/30] Conflicts --- src/auth/src/run.ts | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/auth/src/run.ts b/src/auth/src/run.ts index f9dd40a..3c59d5d 100644 --- a/src/auth/src/run.ts +++ b/src/auth/src/run.ts @@ -4,25 +4,7 @@ import fastify, { FastifyInstance } from 'fastify'; import app from './app'; const start = async () => { -<<<<<<< HEAD const f: FastifyInstance = fastify({ logger: { level: 'info' } }); -======= - const envToLogger = { - development: { - transport: { - target: 'pino-pretty', - options: { - translateTime: 'HH:MM:ss Z', - ignore: 'pid,hostname', - }, - }, - }, - production: true, - test: false, - }; - - const f: FastifyInstance = fastify({ logger: envToLogger.development }); ->>>>>>> refs/remotes/origin/nigel/functionBlockMessage process.on('SIGTERM', () => { f.log.warn('Requested to shutdown'); process.exit(134); From ddce5f3839aae73047d895ac555e12b98ea1ce59 Mon Sep 17 00:00:00 2001 From: NigeParis Date: Thu, 18 Dec 2025 20:32:41 +0100 Subject: [PATCH 22/30] Conflicts --- src/chat/src/run.ts | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/chat/src/run.ts b/src/chat/src/run.ts index c96aed0..3c59d5d 100644 --- a/src/chat/src/run.ts +++ b/src/chat/src/run.ts @@ -4,29 +4,11 @@ import fastify, { FastifyInstance } from 'fastify'; import app from './app'; const start = async () => { -<<<<<<< HEAD const f: FastifyInstance = fastify({ logger: { level: 'info' } }); process.on('SIGTERM', () => { f.log.warn('Requested to shutdown'); process.exit(134); }); -======= - const envToLogger = { - development: { - transport: { - target: 'pino-pretty', - options: { - translateTime: 'HH:MM:ss Z', - ignore: 'pid,hostname', - }, - }, - }, - production: true, - test: false, - }; - - const f: FastifyInstance = fastify({ logger: envToLogger.development }); ->>>>>>> refs/remotes/origin/nigel/functionBlockMessage try { await f.register(app, {}); await f.listen({ port: 80, host: '0.0.0.0' }); From 01f278a947e3e885adf60f55abd61d6315853eb4 Mon Sep 17 00:00:00 2001 From: NigeParis Date: Fri, 19 Dec 2025 08:56:32 +0100 Subject: [PATCH 23/30] turned off console.logs to see clearly on the WIP block user --- src/chat/src/app.ts | 68 +++++++++++++++++++-------------------- src/chat/src/broadcast.ts | 19 +++++++---- 2 files changed, 47 insertions(+), 40 deletions(-) diff --git a/src/chat/src/app.ts b/src/chat/src/app.ts index f40f88e..4c887e0 100644 --- a/src/chat/src/app.ts +++ b/src/chat/src/app.ts @@ -169,7 +169,7 @@ async function onReady(fastify: FastifyInstance) { broadcast(fastify, obj, obj.SenderWindowID); const users: User[] = fastify.db.getAllUsers() ?? []; - console.log('DEBUG: senderWindow :', getUserById(users, obj.SenderUserID)?.name); + // console.log('DEBUG: senderWindow :', getUserById(users, obj.SenderUserID)?.name); @@ -228,7 +228,7 @@ async function onReady(fastify: FastifyInstance) { const clientName = clientInfo?.user; if (!clientName) return; - console.log(color.green, `Client logging out: ${clientName} (${socket.id})`); + // console.log(color.green, `Client logging out: ${clientName} (${socket.id})`); const obj: ClientMessage = { command: '', destination: 'system-info', @@ -254,11 +254,11 @@ async function onReady(fastify: FastifyInstance) { socket.on('disconnecting', (reason) => { const clientName = clientChat.get(socket.id)?.user || null; - console.log( - color.green, - `Client disconnecting: ${clientName} (${socket.id}) reason:`, - reason, - ); + // console.log( + // color.green, + // `Client disconnecting: ${clientName} (${socket.id}) reason:`, + // reason, + // ); if (reason === 'transport error') return; if (clientName !== null) { @@ -285,12 +285,12 @@ async function onReady(fastify: FastifyInstance) { socket.on('client_left', (data) => { const clientName = clientChat.get(socket.id)?.user || null; - const leftChat = data || null; - console.log( - color.green, - `Left the Chat User: ${clientName} id Socket: ${socket.id} reason:`, - leftChat.why, - ); + //const leftChat = data || null; + // console.log( + // color.green, + // `Left the Chat User: ${clientName} id Socket: ${socket.id} reason:`, + // leftChat.why, + // ); if (clientName !== null) { const obj: ClientMessage = { @@ -320,11 +320,11 @@ async function onReady(fastify: FastifyInstance) { socket.on('privMessage', (data) => { const clientName: string = clientChat.get(socket.id)?.user || ''; const prvMessage: ClientMessage = JSON.parse(data) || ''; - console.log( - color.blue, - `DEBUG LOG: ClientName: '${clientName}' id Socket: '${socket.id}' target Name:`, - prvMessage.command, - ); + // console.log( + // color.blue, + // `DEBUG LOG: ClientName: '${clientName}' id Socket: '${socket.id}' target Name:`, + // prvMessage.command, + // ); if (clientName !== null) { const obj: ClientMessage = { @@ -352,14 +352,14 @@ async function onReady(fastify: FastifyInstance) { socket.on('profilMessage', async (data: string) => { const clientName: string = clientChat.get(socket.id)?.user || ''; const profilMessage: ClientMessage = JSON.parse(data) || ''; - const users: User[] = fastify.db.getAllUsers() ?? []; + // const users: User[] = fastify.db.getAllUsers() ?? []; // console.log(color.yellow, 'DEBUG LOG: ALL USERS EVER CONNECTED:', users); // console.log(color.blue, `DEBUG LOG: ClientName: '${clientName}' id Socket: '${socket.id}' target profil:`, profilMessage.user); const profile: ClientProfil = await makeProfil(fastify, profilMessage.user, socket); if (clientName !== null) { - const testuser: User | null = getUserByName(users, profilMessage.user); - console.log(color.yellow, 'user:', testuser?.name ?? 'Guest'); - console.log(color.blue, 'DEBUG - profil message MESSAGE OUT :', profile.SenderWindowID); + // const testuser: User | null = getUserByName(users, profilMessage.user); + // console.log(color.yellow, 'user:', testuser?.name ?? 'Guest'); + // console.log(color.blue, 'DEBUG - profil message MESSAGE OUT :', profile.SenderWindowID); sendProfil(fastify, profile, profile.SenderWindowID); // clientChat.delete(obj.user); } @@ -458,14 +458,14 @@ async function onReady(fastify: FastifyInstance) { if (userAreBlocked) { - console.log(color.green, 'Both users are blocked as requested'); + // console.log(color.green, 'Both users are blocked as requested'); // return true; // or any other action you need to take - console.log(color.red, 'ALL BLOCKED USERS:', usersBlocked); + // console.log(color.red, 'ALL BLOCKED USERS:', usersBlocked); fastify.db.removeBlockedUserFor(UserAskingToBlock!.id, UserToBlock!.id); - const usersBlocked2 = fastify.db.getAllBlockedUsers(); - console.log(color.green, 'remove A BLOCKED USER:', usersBlocked2); + // const usersBlocked2 = fastify.db.getAllBlockedUsers(); + // console.log(color.green, 'remove A BLOCKED USER:', usersBlocked2); if (clientName !== null) { const blockedMessage = 'I have un-blocked you'; if (clientName !== null) { @@ -500,11 +500,11 @@ async function onReady(fastify: FastifyInstance) { } else { - console.log(color.red, 'The users are not blocked in this way'); - console.log(color.red, 'ALL BLOCKED USERS:', usersBlocked); + // console.log(color.red, 'The users are not blocked in this way'); + // console.log(color.red, 'ALL BLOCKED USERS:', usersBlocked); fastify.db.addBlockedUserFor(UserAskingToBlock!.id, UserToBlock!.id); - const usersBlocked2 = fastify.db.getAllBlockedUsers(); - console.log(color.green, 'ALL BLOCKED USERS:', usersBlocked2); + // const usersBlocked2 = fastify.db.getAllBlockedUsers(); + // console.log(color.green, 'ALL BLOCKED USERS:', usersBlocked2); if (clientName !== null) { const blockedMessage = 'I have blocked you'; profilBlock.Sendertext = 'You have blocked '; @@ -563,10 +563,10 @@ async function onReady(fastify: FastifyInstance) { // client.user = clientName; // } } - console.log( - color.green, - `Client entered the Chat: ${clientName} (${socket.id})`, - ); + // console.log( + // color.green, + // `Client entered the Chat: ${clientName} (${socket.id})`, + // ); if (clientName !== null) { const obj: ClientMessage = { command: '', diff --git a/src/chat/src/broadcast.ts b/src/chat/src/broadcast.ts index 50fd98b..c9d2b5b 100644 --- a/src/chat/src/broadcast.ts +++ b/src/chat/src/broadcast.ts @@ -37,15 +37,22 @@ export function broadcast(fastify: FastifyInstance, data: ClientMessage, sender? //console.log(color.yellow, 'me:', getUserByName(AllusersBlocked, data.user)?.id) const UserByName = getUserByName(AllusersBlocked, data.user)?.id ?? ""; const list:BlockRelation[] = whoBlockedMe(fastify, UserByName); - const blockers = list.map(r => r.blocker); -const blocked = list.map(r => r.blocked); -console.log('All blockers:', blockers); -console.log('All blocked:', blocked); + + + + const blockers = list.map(read => read.blocker); + const blocked = list.map(read => read.blocked); + + console.log('All blockers:', blockers); + console.log('All blocked:', blocked); + + + //console.log(color.yellow, 'list:', list) fastify.io.fetchSockets().then((sockets) => { for (const socket of sockets) { // Skip sender's own socket - //if (socket.id === sender) continue; + if (socket.id === sender) continue; // Get client name from map const clientInfo = clientChat.get(socket.id); if (!clientInfo?.user) { @@ -69,7 +76,7 @@ console.log('All blocked:', blocked); // } else { // console.log('FALSE → sender IS blocked'); // } - if (list.filter(entry => entry.blocker === UserByID)) continue; + //if (list.filter(entry => entry.blocker === UserByID)) continue; socket.emit('MsgObjectServer', { message: data }); From f76d27ab628b8217202043bd7b958d57d1a03eb6 Mon Sep 17 00:00:00 2001 From: NigeParis Date: Wed, 17 Dec 2025 09:57:41 +0100 Subject: [PATCH 24/30] WIP Blocked users and clean up obj { } its in constitant --- frontend/src/pages/chat/chat.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend/src/pages/chat/chat.ts b/frontend/src/pages/chat/chat.ts index 2998eef..a1070bf 100644 --- a/frontend/src/pages/chat/chat.ts +++ b/frontend/src/pages/chat/chat.ts @@ -31,7 +31,6 @@ export type blockedUnBlocked = by: string, }; - // get the name of the machine used to connect const machineHostName = window.location.hostname; console.log('connect to login at %chttps://' + machineHostName + ':8888/app/login',color.yellow); From cd621e6c1a24e800e475ed527300a027aeb383fe Mon Sep 17 00:00:00 2001 From: NigeParis Date: Wed, 17 Dec 2025 10:20:07 +0100 Subject: [PATCH 25/30] Cleaned un the type obj - now consistant through out --- frontend/src/pages/chat/chat.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/frontend/src/pages/chat/chat.ts b/frontend/src/pages/chat/chat.ts index a1070bf..02d0b16 100644 --- a/frontend/src/pages/chat/chat.ts +++ b/frontend/src/pages/chat/chat.ts @@ -31,6 +31,21 @@ export type blockedUnBlocked = by: string, }; +export type obj = +{ + command: string, + destination: string, + type: string, + user: string, + frontendUserName: string, + frontendUser: string, + token: string, + text: string, + timestamp: number, + SenderWindowID: string, + Sendertext: string, +}; + // get the name of the machine used to connect const machineHostName = window.location.hostname; console.log('connect to login at %chttps://' + machineHostName + ':8888/app/login',color.yellow); From cd0f2bd3d28af0c49dbbbf60465c7dc2f51b04bf Mon Sep 17 00:00:00 2001 From: NigeParis Date: Fri, 19 Dec 2025 08:56:32 +0100 Subject: [PATCH 26/30] turned off console.logs to see clearly on the WIP block user --- src/chat/src/app.ts | 68 +++++++++++++++++++-------------------- src/chat/src/broadcast.ts | 19 +++++++---- 2 files changed, 47 insertions(+), 40 deletions(-) diff --git a/src/chat/src/app.ts b/src/chat/src/app.ts index f40f88e..4c887e0 100644 --- a/src/chat/src/app.ts +++ b/src/chat/src/app.ts @@ -169,7 +169,7 @@ async function onReady(fastify: FastifyInstance) { broadcast(fastify, obj, obj.SenderWindowID); const users: User[] = fastify.db.getAllUsers() ?? []; - console.log('DEBUG: senderWindow :', getUserById(users, obj.SenderUserID)?.name); + // console.log('DEBUG: senderWindow :', getUserById(users, obj.SenderUserID)?.name); @@ -228,7 +228,7 @@ async function onReady(fastify: FastifyInstance) { const clientName = clientInfo?.user; if (!clientName) return; - console.log(color.green, `Client logging out: ${clientName} (${socket.id})`); + // console.log(color.green, `Client logging out: ${clientName} (${socket.id})`); const obj: ClientMessage = { command: '', destination: 'system-info', @@ -254,11 +254,11 @@ async function onReady(fastify: FastifyInstance) { socket.on('disconnecting', (reason) => { const clientName = clientChat.get(socket.id)?.user || null; - console.log( - color.green, - `Client disconnecting: ${clientName} (${socket.id}) reason:`, - reason, - ); + // console.log( + // color.green, + // `Client disconnecting: ${clientName} (${socket.id}) reason:`, + // reason, + // ); if (reason === 'transport error') return; if (clientName !== null) { @@ -285,12 +285,12 @@ async function onReady(fastify: FastifyInstance) { socket.on('client_left', (data) => { const clientName = clientChat.get(socket.id)?.user || null; - const leftChat = data || null; - console.log( - color.green, - `Left the Chat User: ${clientName} id Socket: ${socket.id} reason:`, - leftChat.why, - ); + //const leftChat = data || null; + // console.log( + // color.green, + // `Left the Chat User: ${clientName} id Socket: ${socket.id} reason:`, + // leftChat.why, + // ); if (clientName !== null) { const obj: ClientMessage = { @@ -320,11 +320,11 @@ async function onReady(fastify: FastifyInstance) { socket.on('privMessage', (data) => { const clientName: string = clientChat.get(socket.id)?.user || ''; const prvMessage: ClientMessage = JSON.parse(data) || ''; - console.log( - color.blue, - `DEBUG LOG: ClientName: '${clientName}' id Socket: '${socket.id}' target Name:`, - prvMessage.command, - ); + // console.log( + // color.blue, + // `DEBUG LOG: ClientName: '${clientName}' id Socket: '${socket.id}' target Name:`, + // prvMessage.command, + // ); if (clientName !== null) { const obj: ClientMessage = { @@ -352,14 +352,14 @@ async function onReady(fastify: FastifyInstance) { socket.on('profilMessage', async (data: string) => { const clientName: string = clientChat.get(socket.id)?.user || ''; const profilMessage: ClientMessage = JSON.parse(data) || ''; - const users: User[] = fastify.db.getAllUsers() ?? []; + // const users: User[] = fastify.db.getAllUsers() ?? []; // console.log(color.yellow, 'DEBUG LOG: ALL USERS EVER CONNECTED:', users); // console.log(color.blue, `DEBUG LOG: ClientName: '${clientName}' id Socket: '${socket.id}' target profil:`, profilMessage.user); const profile: ClientProfil = await makeProfil(fastify, profilMessage.user, socket); if (clientName !== null) { - const testuser: User | null = getUserByName(users, profilMessage.user); - console.log(color.yellow, 'user:', testuser?.name ?? 'Guest'); - console.log(color.blue, 'DEBUG - profil message MESSAGE OUT :', profile.SenderWindowID); + // const testuser: User | null = getUserByName(users, profilMessage.user); + // console.log(color.yellow, 'user:', testuser?.name ?? 'Guest'); + // console.log(color.blue, 'DEBUG - profil message MESSAGE OUT :', profile.SenderWindowID); sendProfil(fastify, profile, profile.SenderWindowID); // clientChat.delete(obj.user); } @@ -458,14 +458,14 @@ async function onReady(fastify: FastifyInstance) { if (userAreBlocked) { - console.log(color.green, 'Both users are blocked as requested'); + // console.log(color.green, 'Both users are blocked as requested'); // return true; // or any other action you need to take - console.log(color.red, 'ALL BLOCKED USERS:', usersBlocked); + // console.log(color.red, 'ALL BLOCKED USERS:', usersBlocked); fastify.db.removeBlockedUserFor(UserAskingToBlock!.id, UserToBlock!.id); - const usersBlocked2 = fastify.db.getAllBlockedUsers(); - console.log(color.green, 'remove A BLOCKED USER:', usersBlocked2); + // const usersBlocked2 = fastify.db.getAllBlockedUsers(); + // console.log(color.green, 'remove A BLOCKED USER:', usersBlocked2); if (clientName !== null) { const blockedMessage = 'I have un-blocked you'; if (clientName !== null) { @@ -500,11 +500,11 @@ async function onReady(fastify: FastifyInstance) { } else { - console.log(color.red, 'The users are not blocked in this way'); - console.log(color.red, 'ALL BLOCKED USERS:', usersBlocked); + // console.log(color.red, 'The users are not blocked in this way'); + // console.log(color.red, 'ALL BLOCKED USERS:', usersBlocked); fastify.db.addBlockedUserFor(UserAskingToBlock!.id, UserToBlock!.id); - const usersBlocked2 = fastify.db.getAllBlockedUsers(); - console.log(color.green, 'ALL BLOCKED USERS:', usersBlocked2); + // const usersBlocked2 = fastify.db.getAllBlockedUsers(); + // console.log(color.green, 'ALL BLOCKED USERS:', usersBlocked2); if (clientName !== null) { const blockedMessage = 'I have blocked you'; profilBlock.Sendertext = 'You have blocked '; @@ -563,10 +563,10 @@ async function onReady(fastify: FastifyInstance) { // client.user = clientName; // } } - console.log( - color.green, - `Client entered the Chat: ${clientName} (${socket.id})`, - ); + // console.log( + // color.green, + // `Client entered the Chat: ${clientName} (${socket.id})`, + // ); if (clientName !== null) { const obj: ClientMessage = { command: '', diff --git a/src/chat/src/broadcast.ts b/src/chat/src/broadcast.ts index 50fd98b..c9d2b5b 100644 --- a/src/chat/src/broadcast.ts +++ b/src/chat/src/broadcast.ts @@ -37,15 +37,22 @@ export function broadcast(fastify: FastifyInstance, data: ClientMessage, sender? //console.log(color.yellow, 'me:', getUserByName(AllusersBlocked, data.user)?.id) const UserByName = getUserByName(AllusersBlocked, data.user)?.id ?? ""; const list:BlockRelation[] = whoBlockedMe(fastify, UserByName); - const blockers = list.map(r => r.blocker); -const blocked = list.map(r => r.blocked); -console.log('All blockers:', blockers); -console.log('All blocked:', blocked); + + + + const blockers = list.map(read => read.blocker); + const blocked = list.map(read => read.blocked); + + console.log('All blockers:', blockers); + console.log('All blocked:', blocked); + + + //console.log(color.yellow, 'list:', list) fastify.io.fetchSockets().then((sockets) => { for (const socket of sockets) { // Skip sender's own socket - //if (socket.id === sender) continue; + if (socket.id === sender) continue; // Get client name from map const clientInfo = clientChat.get(socket.id); if (!clientInfo?.user) { @@ -69,7 +76,7 @@ console.log('All blocked:', blocked); // } else { // console.log('FALSE → sender IS blocked'); // } - if (list.filter(entry => entry.blocker === UserByID)) continue; + //if (list.filter(entry => entry.blocker === UserByID)) continue; socket.emit('MsgObjectServer', { message: data }); From 9f0e626e2948fbe75d5f5893842a98aaa936ddee Mon Sep 17 00:00:00 2001 From: NigeParis Date: Fri, 19 Dec 2025 09:13:45 +0100 Subject: [PATCH 27/30] fixed broken compile --- frontend/src/pages/chat/chat.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/pages/chat/chat.ts b/frontend/src/pages/chat/chat.ts index 02d0b16..88e11f7 100644 --- a/frontend/src/pages/chat/chat.ts +++ b/frontend/src/pages/chat/chat.ts @@ -9,7 +9,7 @@ import { getProfil } from './getProfil'; import { addMessage } from './addMessage'; import { broadcastMsg } from './broadcastMsg'; import { isLoggedIn } from './isLoggedIn'; -import type { ClientMessage, ClientProfil, obj } from './types_front'; +import type { ClientMessage, ClientProfil } from './types_front'; import { openProfilePopup } from './openProfilePopup'; import { actionBtnPopUpClear } from './actionBtnPopUpClear'; import { actionBtnPopUpBlock } from './actionBtnPopUpBlock'; From 2299294f0e892d80c114d0baca5378a8512521c7 Mon Sep 17 00:00:00 2001 From: NigeParis Date: Fri, 19 Dec 2025 10:01:27 +0100 Subject: [PATCH 28/30] rebased Master amd eslint - activated logs Raph for merge with master because eslint makes problems with graphana not activated --- Docker.mk | 14 +- src/chat/src/app.ts | 212 +++++++++++----------------- src/chat/src/broadcast.ts | 62 +++----- src/chat/src/filter_Blocked_user.ts | 34 ++--- src/chat/src/isUser_BlockedBy_me.ts | 22 +-- src/chat/src/routes/broadcast.ts | 3 +- 6 files changed, 135 insertions(+), 212 deletions(-) diff --git a/Docker.mk b/Docker.mk index f63b928..1ea71bb 100644 --- a/Docker.mk +++ b/Docker.mk @@ -6,7 +6,7 @@ # By: nrobinso +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2025/06/11 18:10:26 by maiboyer #+# #+# # -# Updated: 2025/12/17 11:34:56 by nrobinso ### ########.fr # +# Updated: 2025/12/19 09:19:02 by nrobinso ### ########.fr # # # # **************************************************************************** # @@ -14,12 +14,12 @@ # TODO: REMOVE THIS BEFORE LAUNCH # this allows the us to only start the non-monitoring sercices -DOCKER_SERVICE= \ - auth \ - chat \ - frontend \ - nginx \ - user \ +# DOCKER_SERVICE= +# auth \ +# chat \ +# frontend \ +# nginx \ +# user \ all: build docker compose up -d $(DOCKER_SERVICE) diff --git a/src/chat/src/app.ts b/src/chat/src/app.ts index 4c887e0..3a392d1 100644 --- a/src/chat/src/app.ts +++ b/src/chat/src/app.ts @@ -20,7 +20,6 @@ import { sendProfil } from './sendProfil'; import { setGameLink } from './setGameLink'; import { nextGame_SocketListener } from './nextGame_SocketListener'; import { list_SocketListener } from './list_SocketListener'; -import { filter_Blocked_user } from './filter_Blocked_user' // colors for console.log export const color = { @@ -42,7 +41,7 @@ interface ClientInfo { } -export type blockedUnBlocked = +export type blockedUnBlocked = { userState: string, userTarget: string, @@ -104,15 +103,13 @@ declare module 'fastify' { client_left: (userName: string, why: string) => void; list: (oldUser: string, user: string) => void; updateClientName: (oldUser: string, user: string) => void; - blockBtn: (data: blockedUnBlocked) => void; - isBlockdBtn: (data: blockedUnBlocked) => void; - check_Block_button: (data: blockedUnBlocked) => void; + blockBtn: (data: blockedUnBlocked) => void; + isBlockdBtn: (data: blockedUnBlocked) => void; + check_Block_button: (data: blockedUnBlocked) => void; }>; } } - - /** * function get the object user in an array of users[] by name * @param users @@ -128,25 +125,25 @@ function isUser_BlockedBy_me(fastify: FastifyInstance, blockedBy_Id : string, is if (!users) return ''; const UserToBlock: User | null = getUserById(users, `${isBlocked_Id}`); const UserAskingToBlock: User | null = getUserById(users, `${blockedBy_Id}`); - if (!UserToBlock) {console.log(color.blue, `'User: ${UserAskingToBlock?.id} has not blocked' ${isBlocked_Id}`); return ""}; - if (!UserAskingToBlock) {console.log(color.blue, `'User: ${UserToBlock?.id} has not blocked by' ${blockedBy_Id}`); return ""}; + if (!UserToBlock) { + console.log(color.blue, `'User: ${UserAskingToBlock?.id} has not blocked' ${isBlocked_Id}`); + return ''; + }; + if (!UserAskingToBlock) { + console.log(color.blue, `'User: ${UserToBlock?.id} has not blocked by' ${blockedBy_Id}`); + return ''; + }; const usersBlocked: BlockedData[] = fastify.db.getAllBlockedUsers() ?? []; const userAreBlocked: boolean = isBlocked(UserAskingToBlock, UserToBlock, usersBlocked); if (userAreBlocked) { - console.log(color.yellow, `'User :${UserAskingToBlock.name}) Hhas UN blocked ${UserToBlock.name}`) + console.log(color.yellow, `'User :${UserAskingToBlock.name}) Hhas UN blocked ${UserToBlock.name}`); return UserAskingToBlock.name; } - console.log(color.blue, `'User :${UserAskingToBlock.name}) has BBBblocked ${UserToBlock.name}`) - - return ""; + console.log(color.blue, `'User :${UserAskingToBlock.name}) has BBBblocked ${UserToBlock.name}`); + return ''; }; - - - async function onReady(fastify: FastifyInstance) { - - // shows address for connection au server transcendance const session = process.env.SESSION_MANAGER ?? ''; if (session) { @@ -155,9 +152,7 @@ async function onReady(fastify: FastifyInstance) { console.log(color.yellow, 'Connect at : https://' + machineName + ':8888/app/login'); } - fastify.io.on('connection', (socket: Socket) => { - socket.on('message', (message: string) => { // console.info(color.blue, 'DEBUG LOG: Socket connected!', color.reset, socket.id); // console.log( color.blue, 'DEBUG LOG: Received message from client', color.reset, message); @@ -167,45 +162,26 @@ async function onReady(fastify: FastifyInstance) { socket.emit('welcome', { msg: 'Welcome to the chat! : ' }); // Send object directly — DO NOT wrap it in a string broadcast(fastify, obj, obj.SenderWindowID); - - const users: User[] = fastify.db.getAllUsers() ?? []; + + // const users: User[] = fastify.db.getAllUsers() ?? []; // console.log('DEBUG: senderWindow :', getUserById(users, obj.SenderUserID)?.name); - - - - - // fastify.io.fetchSockets().then((sockets) => { - // for (const socket of sockets) { - // const clientInfo = clientChat.get(socket.id); - // if (!clientInfo?.user) { - // console.log(color.yellow, `Skipping socket ${socket.id} (no user found)`); - // continue; - // } - // console.log('DEBUG: UserIDWindow :', getUserByName(users, clientInfo.user)?.id); - // const IDUser = getUserByName(users, clientInfo.user)?.id; - - // console.log(filter_Blocked_user(fastify, obj, IDUser?? "")); - - - // } - // }); - - - - - - - - - + // fastify.io.fetchSockets().then((sockets) => { + // for (const socket of sockets) { + // const clientInfo = clientChat.get(socket.id); + // if (!clientInfo?.user) { + // console.log(color.yellow, `Skipping socket ${socket.id} (no user found)`); + // continue; + // } + // console.log('DEBUG: UserIDWindow :', getUserByName(users, clientInfo.user)?.id); + // const IDUser = getUserByName(users, clientInfo.user)?.id; + // console.log(filter_Blocked_user(fastify, obj, IDUser?? "")); + // } + // }); // console.log(color.red, 'DEBUG LOG: connected in the Chat :', connectedUser(fastify.io), color.reset); }); - nextGame_SocketListener(fastify, socket); - list_SocketListener(fastify, socket); - socket.on('updateClientName', (object) => { const userFromFrontend = object || null; const client = clientChat.get(socket.id) || null; @@ -241,9 +217,9 @@ async function onReady(fastify: FastifyInstance) { timestamp: Date.now(), SenderWindowID: socket.id, Sendertext: '', - userID: '', - SenderUserName: '', - SenderUserID: '', + userID: '', + SenderUserName: '', + SenderUserID: '', }; broadcast(fastify, obj, socket.id); // Optional: remove from map @@ -254,11 +230,7 @@ async function onReady(fastify: FastifyInstance) { socket.on('disconnecting', (reason) => { const clientName = clientChat.get(socket.id)?.user || null; - // console.log( - // color.green, - // `Client disconnecting: ${clientName} (${socket.id}) reason:`, - // reason, - // ); + // console.log(color.green, `Client disconnecting: ${clientName} (${socket.id}) reason:`, reason,); if (reason === 'transport error') return; if (clientName !== null) { @@ -275,7 +247,7 @@ async function onReady(fastify: FastifyInstance) { SenderWindowID: socket.id, Sendertext: '', userID: '', - SenderUserName: '', + SenderUserName: '', SenderUserID: '', }; @@ -284,14 +256,9 @@ async function onReady(fastify: FastifyInstance) { }); socket.on('client_left', (data) => { + void data; const clientName = clientChat.get(socket.id)?.user || null; - //const leftChat = data || null; - // console.log( - // color.green, - // `Left the Chat User: ${clientName} id Socket: ${socket.id} reason:`, - // leftChat.why, - // ); - + // const leftChat = data || null; console.log(color.green, `Left the Chat User: ${clientName} id Socket: ${socket.id} reason:`, leftChat.why,); if (clientName !== null) { const obj: ClientMessage = { command: '', @@ -305,8 +272,8 @@ async function onReady(fastify: FastifyInstance) { timestamp: Date.now(), SenderWindowID: socket.id, Sendertext: '', - userID: '', - SenderUserName: '', + userID: '', + SenderUserName: '', SenderUserID: '', }; // console.log(color.blue, 'DEBUG LOG: BROADCASTS OUT :', obj.SenderWindowID); @@ -320,12 +287,7 @@ async function onReady(fastify: FastifyInstance) { socket.on('privMessage', (data) => { const clientName: string = clientChat.get(socket.id)?.user || ''; const prvMessage: ClientMessage = JSON.parse(data) || ''; - // console.log( - // color.blue, - // `DEBUG LOG: ClientName: '${clientName}' id Socket: '${socket.id}' target Name:`, - // prvMessage.command, - // ); - + // console.log(color.blue, `DEBUG LOG: ClientName: '${clientName}' id Socket: '${socket.id}' target Name:`, prvMessage.command,); if (clientName !== null) { const obj: ClientMessage = { command: prvMessage.command, @@ -339,13 +301,13 @@ async function onReady(fastify: FastifyInstance) { timestamp: Date.now(), SenderWindowID: socket.id, Sendertext: '', - userID: '', - SenderUserName: '', + userID: '', + SenderUserName: '', SenderUserID:'', }; // console.log(color.blue, 'DEBUG LOG: PRIV MESSAGE OUT :', obj.SenderWindowID); sendPrivMessage(fastify, obj, obj.SenderWindowID); - // clientChat.delete(obj.user); + // clientChat.delete(obj.user); } }); @@ -361,7 +323,7 @@ async function onReady(fastify: FastifyInstance) { // console.log(color.yellow, 'user:', testuser?.name ?? 'Guest'); // console.log(color.blue, 'DEBUG - profil message MESSAGE OUT :', profile.SenderWindowID); sendProfil(fastify, profile, profile.SenderWindowID); - // clientChat.delete(obj.user); + // clientChat.delete(obj.user); } }); @@ -392,30 +354,24 @@ async function onReady(fastify: FastifyInstance) { if (!UserAskingToBlock || !UserToBlock) return; - if(isUser_BlockedBy_me(fastify, UserAskingToBlock!.id, UserToBlock!.id)) { - const message: blockedUnBlocked = - { - userState: "block", - userTarget: UserToBlock.name, - by: UserAskingToBlock.name, - - - }; - socket.emit('blockBtn', message); - } else { - - const message: blockedUnBlocked = - { - userState: "un-block", - userTarget: UserToBlock.name, - by: UserAskingToBlock.name, - - }; - socket.emit('blockBtn', message); - - - } }); + if (isUser_BlockedBy_me(fastify, UserAskingToBlock!.id, UserToBlock!.id)) { + const message: blockedUnBlocked = { + userState: 'block', + userTarget: UserToBlock.name, + by: UserAskingToBlock.name, + }; + socket.emit('blockBtn', message); + } + else { + const message: blockedUnBlocked = { + userState: 'un-block', + userTarget: UserToBlock.name, + by: UserAskingToBlock.name, + }; + socket.emit('blockBtn', message); + } + }); socket.on('blockUser', async (data: string) => { const clientName: string = clientChat.get(socket.id)?.user || ''; @@ -433,35 +389,27 @@ async function onReady(fastify: FastifyInstance) { const usersBlocked: BlockedData[] = fastify.db.getAllBlockedUsers() ?? []; if (!UserAskingToBlock || !UserToBlock || !usersBlocked) return; const userAreBlocked: boolean = isBlocked(UserAskingToBlock, UserToBlock, usersBlocked); - if(isUser_BlockedBy_me(fastify, UserAskingToBlock!.id, UserToBlock!.id)) { - const message: blockedUnBlocked = - { - userState: "un-block", - userTarget: "", - by: "", - - }; - socket.emit('blockBtn', message); - } else { - - const message: blockedUnBlocked = - { - userState: "block", - userTarget: UserToBlock.name, - by: UserAskingToBlock.name, - - }; - socket.emit('blockBtn', message); - - + if (isUser_BlockedBy_me(fastify, UserAskingToBlock!.id, UserToBlock!.id)) { + const message: blockedUnBlocked = { + userState: 'un-block', + userTarget: '', + by: '', + }; + socket.emit('blockBtn', message); + } + else { + const message: blockedUnBlocked = { + userState: 'block', + userTarget: UserToBlock.name, + by: UserAskingToBlock.name, + }; + socket.emit('blockBtn', message); } - if (userAreBlocked) { // console.log(color.green, 'Both users are blocked as requested'); // return true; // or any other action you need to take - // console.log(color.red, 'ALL BLOCKED USERS:', usersBlocked); fastify.db.removeBlockedUserFor(UserAskingToBlock!.id, UserToBlock!.id); // const usersBlocked2 = fastify.db.getAllBlockedUsers(); @@ -488,7 +436,7 @@ async function onReady(fastify: FastifyInstance) { } // profilBlock.Sendertext = `'You have un-blocked '`; sendBlocked(fastify, blockedMessage, profilBlock); - // const message: blockedUnBlocked = + // const message: blockedUnBlocked = // { // userState: "un-block", // userTarget: "", @@ -527,7 +475,7 @@ async function onReady(fastify: FastifyInstance) { // clientChat.delete(obj.user); } sendBlocked(fastify, blockedMessage, profilBlock); - // const message: blockedUnBlocked = + // const message: blockedUnBlocked = // { // userState: "block", // userTarget: UserToBlock.name, @@ -579,9 +527,9 @@ async function onReady(fastify: FastifyInstance) { text: text, timestamp: Date.now(), SenderWindowID: socket.id, - Sendertext: "", - userID: '', - SenderUserName: '', + Sendertext: '', + userID: '', + SenderUserName: '', SenderUserID: '', }; broadcast(fastify, obj, obj.SenderWindowID); diff --git a/src/chat/src/broadcast.ts b/src/chat/src/broadcast.ts index c9d2b5b..58e2485 100644 --- a/src/chat/src/broadcast.ts +++ b/src/chat/src/broadcast.ts @@ -1,54 +1,37 @@ import type { ClientMessage } from './chat_types'; -import { clientChat, color } from './app'; +import { clientChat } from './app'; import { FastifyInstance } from 'fastify'; -import type { BlockedData } from '@shared/database/mixin/blocked'; import { getUserByName } from './getUserByName'; import type { User } from '@shared/database/mixin/user'; - - type BlockRelation = { blocked: string; blocker: string; }; -function whoBlockedMe( - fastify: FastifyInstance, - myName: string -):BlockRelation [] { - const usersBlocked = +function whoBlockedMe(fastify: FastifyInstance, myID: string): BlockRelation [] { + const usersBlocked = fastify.db.getAllBlockedUsers() ?? []; return usersBlocked - .filter(entry => entry.blocked === myName) + .filter(entry => entry.blocked === myID) .map(entry => ({ blocked: entry.user, blocker: entry.blocked, })); } - - - - export function broadcast(fastify: FastifyInstance, data: ClientMessage, sender?: string) { const AllusersBlocked: User[] = fastify.db.getAllUsers() ?? []; - //console.log(color.yellow, 'me:', getUserByName(AllusersBlocked, data.user)?.id) - const UserByName = getUserByName(AllusersBlocked, data.user)?.id ?? ""; - const list:BlockRelation[] = whoBlockedMe(fastify, UserByName); - - - - const blockers = list.map(read => read.blocker); - const blocked = list.map(read => read.blocked); - - console.log('All blockers:', blockers); - console.log('All blocked:', blocked); - - - - //console.log(color.yellow, 'list:', list) + // console.log(color.yellow, 'me:', getUserByName(AllusersBlocked, data.user)?.id) + const UserID = getUserByName(AllusersBlocked, data.user)?.id ?? ''; + const list:BlockRelation[] = whoBlockedMe(fastify, UserID); + const blockers = list.map(read => read.blocker); + const blocked = list.map(read => read.blocked); + console.log('All blockers:', blockers); + console.log('All blocked:', blocked); + // console.log(color.yellow, 'list:', list) fastify.io.fetchSockets().then((sockets) => { for (const socket of sockets) { // Skip sender's own socket @@ -56,32 +39,25 @@ export function broadcast(fastify: FastifyInstance, data: ClientMessage, sender? // Get client name from map const clientInfo = clientChat.get(socket.id); if (!clientInfo?.user) { - //console.log(color.yellow, `Skipping socket ${socket.id} (no user found)`); + // console.log(color.yellow, `Skipping socket ${socket.id} (no user found)`); continue; } // console.log('BLOCKED MAYBE', getUserById(sender)); // console.log('TARGET',socket.id ); // Emit structured JSON object - - const UserByName = getUserByName(AllusersBlocked, data.user)?.name ?? ""; - const UserByID = getUserByName(AllusersBlocked, data.user)?.id ?? ""; - //console.log(color.blue, 'Asking:', UserByName); - //console.log(color.blue, 'Asking ID:', UserByID); - + // const UserID = getUserByName(AllusersBlocked, data.user)?.name ?? ""; + // const UserByID = getUserByName(AllusersBlocked, data.user)?.id ?? ""; + // console.log(color.blue, 'Asking:', UserID); + // console.log(color.blue, 'Asking ID:', UserByID); console.log('Blocked list:', list); - //console.log('Sender ID:', UserByID); - + // console.log('Sender ID:', UserByID); // if (!list.includes(UserByID)) { // console.log('TRUE → sender NOT blocked'); // } else { // console.log('FALSE → sender IS blocked'); // } - //if (list.filter(entry => entry.blocker === UserByID)) continue; + // if (list.filter(entry => entry.blocker === UserByID)) continue; socket.emit('MsgObjectServer', { message: data }); - - - - // Debug logs // console.log(color.green, `'DEBUG LOG: Broadcast to:', ${data.command} message: ${data.text}`); } diff --git a/src/chat/src/filter_Blocked_user.ts b/src/chat/src/filter_Blocked_user.ts index 3f96bef..3cdded5 100644 --- a/src/chat/src/filter_Blocked_user.ts +++ b/src/chat/src/filter_Blocked_user.ts @@ -1,4 +1,4 @@ -import type { ClientMessage, ClientProfil } from './chat_types'; +import type { ClientMessage } from './chat_types'; import { FastifyInstance } from 'fastify'; import type { User } from '@shared/database/mixin/user'; import { getUserById } from './getUserById'; @@ -6,8 +6,8 @@ import { isUser_BlockedBy_me } from './isUser_BlockedBy_me'; /** * function to check if blocked or not - checks with ID - * @param fastify - * @param data + * @param fastify + * @param data * @returns true or false - true if blocked user by a user */ @@ -15,25 +15,19 @@ export function filter_Blocked_user(fastify: FastifyInstance, data: ClientMessag const users: User[] = fastify.db.getAllUsers() ?? []; const UserToBlock: string = id; - const UserAskingToBlock: User | null = getUserById(users,`${data.SenderUserID}`); - if (!UserAskingToBlock ) { - // console.log('SOMETHING NULL', data); + const UserAskingToBlock: User | null = getUserById(users, `${data.SenderUserID}`); + if (!UserAskingToBlock) { + // console.log('SOMETHING NULL', data); // console.log('UsetToBlock', UserToBlock?.id); // console.log('UsetToBlock', UserToBlock?.name); // console.log('UsetAskingToBlock', UserAskingToBlock?.id); // console.log('UsetAskingToBlock', UserAskingToBlock?.name); - console.log(''); - - - return false; - } - if(isUser_BlockedBy_me(fastify, UserAskingToBlock!.id, UserToBlock)) - { - return true; - } - else - { return false; - } -} - + } + if (isUser_BlockedBy_me(fastify, UserAskingToBlock!.id, UserToBlock)) { + return true; + } + else { + return false; + } +} \ No newline at end of file diff --git a/src/chat/src/isUser_BlockedBy_me.ts b/src/chat/src/isUser_BlockedBy_me.ts index dcd7bb4..797e027 100644 --- a/src/chat/src/isUser_BlockedBy_me.ts +++ b/src/chat/src/isUser_BlockedBy_me.ts @@ -7,9 +7,9 @@ import { color } from './color'; /** * checks the Db for the two matching Ids - * @param fastify - * @param blockedBy_Id - * @param isBlocked_Id + * @param fastify + * @param blockedBy_Id + * @param isBlocked_Id * @returns Null if not blocked */ @@ -18,15 +18,21 @@ export function isUser_BlockedBy_me(fastify: FastifyInstance, blockedBy_Id : str if (!users) return ''; const UserToBlock: User | null = getUserById(users, `${isBlocked_Id}`); const UserAskingToBlock: User | null = getUserById(users, `${blockedBy_Id}`); - if (!UserToBlock) {console.log(color.blue, `'User: ${UserAskingToBlock?.id} has not blocked' ${isBlocked_Id}`); return ""}; - if (!UserAskingToBlock) {console.log(color.blue, `'User: ${UserToBlock?.id} has not blocked by' ${blockedBy_Id}`); return ""}; + if (!UserToBlock) { + console.log(color.blue, `'User: ${UserAskingToBlock?.id} has not blocked' ${isBlocked_Id}`); + return ''; + } + if (!UserAskingToBlock) { + console.log(color.blue, `'User: ${UserToBlock?.id} has not blocked by' ${blockedBy_Id}`); + return ''; + } const usersBlocked: BlockedData[] = fastify.db.getAllBlockedUsers() ?? []; const userAreBlocked: boolean = isBlocked(UserAskingToBlock, UserToBlock, usersBlocked); if (userAreBlocked) { - console.log(color.yellow, `'User :${UserAskingToBlock.name}) Hhas UN blocked ${UserToBlock.name}`) + console.log(color.yellow, `'User :${UserAskingToBlock.name}) Hhas UN blocked ${UserToBlock.name}`); return UserAskingToBlock.name; } - console.log(color.blue, `'User :${UserAskingToBlock.name}) has BBBblocked ${UserToBlock.name}`) + console.log(color.blue, `'User :${UserAskingToBlock.name}) has BBBblocked ${UserToBlock.name}`); - return ""; + return ''; }; diff --git a/src/chat/src/routes/broadcast.ts b/src/chat/src/routes/broadcast.ts index de46038..e33cbed 100644 --- a/src/chat/src/routes/broadcast.ts +++ b/src/chat/src/routes/broadcast.ts @@ -1,6 +1,5 @@ import { FastifyPluginAsync } from 'fastify'; import { Static, Type } from 'typebox'; -import { broadcast } from '../broadcast'; export const ChatReq = Type.Object({ message: Type.String(), @@ -19,7 +18,7 @@ const route: FastifyPluginAsync = async (fastify): Promise => { config: { requireAuth: false }, }, async function(req, res) { - //broadcast(this, { command: '', destination: '', user: 'CMwaLeSever!!', text: req.body.message, SenderWindowID: 'server' }); + // broadcast(this, { command: '', destination: '', user: 'CMwaLeSever!!', text: req.body.message, SenderWindowID: 'server' }); void res; }, ); From d5278274ea34aeee2e436a7c034e0cffa88e54ab Mon Sep 17 00:00:00 2001 From: Maieul BOYER Date: Fri, 19 Dec 2025 14:37:21 +0100 Subject: [PATCH 29/30] yes --- Docker.mk | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Docker.mk b/Docker.mk index 1ea71bb..5f6efcb 100644 --- a/Docker.mk +++ b/Docker.mk @@ -6,7 +6,7 @@ # By: nrobinso +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2025/06/11 18:10:26 by maiboyer #+# #+# # -# Updated: 2025/12/19 09:19:02 by nrobinso ### ########.fr # +# Updated: 2025/12/19 14:33:21 by maiboyer ### ########.fr # # # # **************************************************************************** # @@ -14,12 +14,13 @@ # TODO: REMOVE THIS BEFORE LAUNCH # this allows the us to only start the non-monitoring sercices -# DOCKER_SERVICE= -# auth \ -# chat \ -# frontend \ -# nginx \ -# user \ +DOCKER_SERVICE= \ + auth \ + chat \ + frontend \ + nginx \ + user \ + all: build docker compose up -d $(DOCKER_SERVICE) From 5b979c888289d7ea872270b2c294404e92b8acfd Mon Sep 17 00:00:00 2001 From: Maieul BOYER Date: Fri, 19 Dec 2025 14:42:54 +0100 Subject: [PATCH 30/30] chore(cleanup): made the chat page not bypassing the auth check anymore --- frontend/src/pages/chat/chat.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/pages/chat/chat.ts b/frontend/src/pages/chat/chat.ts index 88e11f7..868d149 100644 --- a/frontend/src/pages/chat/chat.ts +++ b/frontend/src/pages/chat/chat.ts @@ -587,4 +587,4 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn } }; -addRoute('/chat', handleChat, { bypass_auth: true }); +addRoute('/chat', handleChat);