WIP copy U Game link to sender

This commit is contained in:
NigeParis 2026-01-12 16:28:10 +01:00 committed by Maix0
parent ed2885f19d
commit 432fd849b8
4 changed files with 47 additions and 10 deletions

View file

@ -25,6 +25,11 @@ function getGameNumber():string {
export async function sendInvite(fastify: FastifyInstance, innerHtml: string, profil: ClientProfil) {
const sockets = await fastify.io.fetchSockets();
let targetSocket;
const senderSocket = sockets.find(socket => {
const clientInfo = clientChat.get(socket.id);
return clientInfo?.user === profil.SenderName
});
for (const socket of sockets) {
const clientInfo: string | undefined = clientChat.get(socket.id)?.user || undefined;
targetSocket = socket || null;
@ -33,23 +38,19 @@ export async function sendInvite(fastify: FastifyInstance, innerHtml: string, pr
profil.innerHtml = innerHtml ?? '';
if (targetSocket.id) {
const data: ClientMessage = {
...profil,
command: `@${clientInfo}`,
destination: 'inviteMsg',
type: 'chat',
user: profil.user,
token: '',
text: getGameNumber(),
timestamp: Date.now(),
SenderWindowID: socket.id,
userID: profil.userID,
frontendUserName: '',
frontendUser: '',
SenderUserName: profil.SenderName,
SenderUserID: '',
Sendertext: '',
innerHtml: innerHtml,
};
sendPrivMessage(fastify, data, '');
sendPrivMessage(fastify, data, senderSocket?.id);
}
return;
}

View file

@ -49,7 +49,11 @@ export async function sendPrivMessage(fastify: FastifyInstance, data: ClientMess
socket.emit('MsgObjectServer', { message: data });
fastify.log.info({ senderID: `${UserID}`, msgPriv: data.text, target: `${receiverUser.id}` });
if (senderSocket) {
senderSocket.emit('privMessageCopy', `${data.command}: ${data.text}🔒`);
if (!data.innerHtml)
senderSocket.emit('privMessageCopy', `${data.command}: ${data.text}🔒`);
else
senderSocket.emit('privMessageCopy', `${data.command}: ${data.innerHtml}🔒`);
}
}
}