Fixed in / out chat notification system info

This commit is contained in:
NigeParis 2026-01-13 11:04:37 +01:00 committed by Maix0
parent 2e422eee2a
commit 7e644fe658
7 changed files with 28 additions and 41 deletions

View file

@ -174,10 +174,6 @@ 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("------------------------------------------------")
console.log("PRUV GAME")
console.log(data)
console.log("------------------------------------------------")
if (clientName !== null) {
const obj: ClientMessage = {
command: prvMessage.command,
@ -187,7 +183,7 @@ async function onReady(fastify: FastifyInstance) {
text: prvMessage.text,
timestamp: Date.now(),
SenderWindowID: socket.id,
};``
};
sendPrivMessage(fastify, obj, obj.SenderWindowID);
}
});
@ -221,11 +217,6 @@ async function onReady(fastify: FastifyInstance) {
socket.on('inviteGame', async (data: string) => {
const clientName: string = clientChat.get(socket.id)?.user || '';
const profilInvite: ClientProfil = JSON.parse(data) || '';
console.log("------------------------------------------------")
console.log("INVITE GAME")
console.log(data)
console.log("------------------------------------------------")
const linkGame: PongGameId | undefined = await setGameLink(fastify, data);
if (!linkGame) return;
const link: string = `<a href="https://localhost:8888/app/pong?game=${linkGame}" style="color: blue; text-decoration: underline; cursor: pointer;">Click me</a>`;

View file

@ -23,9 +23,7 @@ export async function sendPrivMessage(fastify: FastifyInstance, data: ClientMess
const sockets = await fastify.io.fetchSockets();
const allUsers: User[] = fastify.db.getAllUsers() ?? [];
console.log('sender', sender);
const senderSocket = sockets.find(socket => socket.id === sender);
console.log('senderSOcket', senderSocket?.id);
for (const socket of sockets) {
if (socket.id === sender) continue;
@ -46,20 +44,16 @@ export async function sendPrivMessage(fastify: FastifyInstance, data: ClientMess
}
blockMsgFlag = checkNamePair(list, UserID, receiverUser.id) || false;
console.log("userID", UserID);
console.log("receiverUserID", receiverUser.id)
if (!blockMsgFlag) {
socket.emit('MsgObjectServer', { message: data });
fastify.log.info({ senderID: `${UserID}`, msgPriv: data.text, target: `${receiverUser.id}` });
if (senderSocket) {
if (!data.innerHtml) {
console.log('privMsg text');
senderSocket.emit('privMessageCopy', `${data.command}: ${data.text}🔒`);
} else {
console.log('privMsg texthtml');
}
else {
senderSocket.emit('privMessageCopy', `${data.command}: ${data.innerHtml}🔒`);
}
}
}
}