WIP copy U Game link to sender
This commit is contained in:
parent
ed2885f19d
commit
432fd849b8
4 changed files with 47 additions and 10 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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}🔒`);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue