Clean-up in progress
This commit is contained in:
parent
8086444098
commit
4f54d5a462
16 changed files with 292 additions and 214 deletions
|
|
@ -21,24 +21,10 @@ import { setGameLink } from './setGameLink';
|
|||
import { nextGame_SocketListener } from './nextGame_SocketListener';
|
||||
import { list_SocketListener } from './chatBackHelperFunctions/list_SocketListener';
|
||||
import { isUser_BlockedBy_me } from './chatBackHelperFunctions/isUser_BlockedBy_me';
|
||||
import type { ClientInfo, blockedUnBlocked } from './chat_types';
|
||||
|
||||
|
||||
declare const __SERVICE_NAME: string;
|
||||
|
||||
interface ClientInfo {
|
||||
user: string;
|
||||
socket: string
|
||||
lastSeen: number;
|
||||
}
|
||||
|
||||
export type blockedUnBlocked =
|
||||
{
|
||||
userState: string,
|
||||
userTarget: string,
|
||||
by: string,
|
||||
};
|
||||
|
||||
|
||||
export const clientChat = new Map<string, ClientInfo>();
|
||||
|
||||
// @ts-expect-error: import.meta.glob is a vite thing. Typescript doesn't know this...
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import { whoBlockedMe } from './whoBlockedMe';
|
|||
export async function broadcast(fastify: FastifyInstance, data: ClientMessage, sender?: string) {
|
||||
|
||||
const Allusers: User[] = fastify.db.getAllUsers() ?? [];
|
||||
if (!data.user) return;
|
||||
const senderUser = getUserByName(Allusers, data.user)
|
||||
if (!senderUser) return;
|
||||
const list:BlockRelation[] = whoBlockedMe(fastify, senderUser.id);
|
||||
|
|
@ -26,7 +27,7 @@ export async function broadcast(fastify: FastifyInstance, data: ClientMessage, s
|
|||
blockMsgFlag = checkNamePair(list, senderUser.id, receiverUser.id) || false;
|
||||
|
||||
const getReceiverGuestConfig = fastify.db.getGuestMessage(receiverUser?.id);
|
||||
if (!getReceiverGuestConfig && senderUser?.guest) continue;
|
||||
if (!getReceiverGuestConfig && senderUser?.guest && data.destination !== 'system-info') continue;
|
||||
if (!blockMsgFlag) {
|
||||
|
||||
socket.emit('MsgObjectServer', { message: data });
|
||||
|
|
|
|||
|
|
@ -36,6 +36,20 @@ export type ClientProfil = {
|
|||
};
|
||||
|
||||
|
||||
export interface ClientInfo {
|
||||
user: string;
|
||||
socket: string
|
||||
lastSeen: number;
|
||||
}
|
||||
|
||||
export type blockedUnBlocked =
|
||||
{
|
||||
userState: string,
|
||||
userTarget: string,
|
||||
by: string,
|
||||
};
|
||||
|
||||
|
||||
// export type obj =
|
||||
// {
|
||||
// command: string,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue