Clean up
This commit is contained in:
parent
4f3aab9b7b
commit
949e5a259a
1 changed files with 14 additions and 17 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
import type { ClientProfil } from './chat_types';
|
import type { ClientProfil } from './chat_types';
|
||||||
import { clientChat, color } from './app';
|
import { clientChat } from './app';
|
||||||
import { FastifyInstance } from 'fastify';
|
import { FastifyInstance } from 'fastify';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -9,21 +9,18 @@ import { FastifyInstance } from 'fastify';
|
||||||
* @param profil
|
* @param profil
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export function sendBlocked(fastify: FastifyInstance, blockedMessage: string, profil: ClientProfil) {
|
export async function sendBlocked(fastify: FastifyInstance, blockedMessage: string, profil: ClientProfil) {
|
||||||
fastify.io.fetchSockets().then((sockets) => {
|
const sockets = await fastify.io.fetchSockets();
|
||||||
let targetSocket;
|
let targetSocket;
|
||||||
for (const socket of sockets) {
|
for (const socket of sockets) {
|
||||||
const clientInfo: string = clientChat.get(socket.id)?.user || '';
|
const clientInfo: string = clientChat.get(socket.id)?.user || '';
|
||||||
if (clientInfo === profil.user) {
|
if (clientInfo === profil.user) {
|
||||||
console.log(color.yellow, 'DEBUG LOG: User found online to block:', profil.user);
|
targetSocket = socket ?? null;
|
||||||
targetSocket = socket || '';
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
profil.text = blockedMessage ?? '';
|
}
|
||||||
// console.log(color.red, 'DEBUG LOG:',profil.Sendertext);
|
profil.text = blockedMessage ?? '';
|
||||||
if (targetSocket) {
|
if (targetSocket) {
|
||||||
targetSocket.emit('blockUser', profil);
|
targetSocket.emit('blockUser', profil);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue