This commit is contained in:
NigeParis 2025-12-30 17:18:56 +01:00 committed by Maix0
parent 1ca84b30c6
commit c6b0225e51
5 changed files with 18 additions and 24 deletions

View file

@ -1,4 +1,4 @@
import type { ClientMessage, BlockRelation} from './chat_types';
import type { ClientMessage, BlockRelation } from './chat_types';
import { clientChat } from './app';
import { FastifyInstance } from 'fastify';
import { getUserByName } from './getUserByName';

View file

@ -1,4 +1,4 @@
import type { BlockRelation} from './chat_types';
import type { BlockRelation } from './chat_types';
export function checkNamePair(list: BlockRelation[], name1: string, name2: string): (boolean) {
const matches: BlockRelation[] = [];

View file

@ -28,7 +28,7 @@ export function sendInvite(fastify: FastifyInstance, innerHtml: string, profil:
const data: ClientMessage = {
command: `@${clientInfo}`,
destination: 'inviteMsg',
type: "chat",
type: 'chat',
user: profil.SenderName,
token: '',
text: ' needs some text to work',

View file

@ -60,28 +60,24 @@ export async function sendPrivMessage(fastify: FastifyInstance, data: ClientMess
}
let blockMsgFlag: boolean = false;
const UserByID = getUserByName(AllusersBlocked, clientInfo.user) ?? '';
if (UserByID === ''){
if (UserByID === '') {
return;
}
const user: string = clientChat.get(socket.id)?.user ?? '';
const atUser = `@${user}`;
console.log(color.red, `'DEBUG LOG:'${atUser}' '${data.command}'`)
if (atUser !== data.command || atUser === '' || data.text === '') {
console.log(color.red, 'DEBUG: atUser !== data.command');
continue;
}
console.log(color.green, `USER ID: ${UserID} userName: ${UserByID.name} iD:${UserByID.id}`);
blockMsgFlag = checkNamePair(list, UserID, UserByID.id) || false;
if (socket.id === sender) {
console.log(color.blue, 'sKip Sender ', socket.id);
continue;
}
console.log(color.yellow, `blockFlag=${blockMsgFlag}: Target ${clientInfo.user}`);
if (!blockMsgFlag) {
console.log(color.blue, 'DEBUG Emit message: ', data.command, 'blockMsgFlag: ', blockMsgFlag);
socket.emit('MsgObjectServer', { message: data });
if (senderSocket) {
senderSocket.emit('privMessageCopy', `${data.command}: ${data.text}🔒`);

View file

@ -1,5 +1,5 @@
import { FastifyInstance } from 'fastify';
import type { BlockRelation} from './chat_types';
import type { BlockRelation } from './chat_types';
export function whoBlockedMe(fastify: FastifyInstance, myID: string): BlockRelation [] {
const usersBlocked =
@ -12,5 +12,3 @@ export function whoBlockedMe(fastify: FastifyInstance, myID: string): BlockRelat
blocker: entry.blocked,
}));
}