WIP - block user

This commit is contained in:
NigeParis 2025-12-18 20:07:07 +01:00
commit 36d767072f
7 changed files with 131 additions and 0 deletions

View file

@ -31,6 +31,23 @@ export type blockedUnBlocked =
by: string,
};
<<<<<<< HEAD
=======
export type obj =
{
command: string,
destination: string,
type: string,
user: string,
frontendUserName: string,
frontendUser: string,
token: string,
text: string,
timestamp: number,
SenderWindowID: string,
Sendertext: string,
};
>>>>>>> refs/remotes/origin/nigel/functionBlockMessage
// get the name of the machine used to connect
const machineHostName = window.location.hostname;

View file

@ -4,7 +4,25 @@ import fastify, { FastifyInstance } from 'fastify';
import app from './app';
const start = async () => {
<<<<<<< HEAD
const f: FastifyInstance = fastify({ logger: { level: 'info' } });
=======
const envToLogger = {
development: {
transport: {
target: 'pino-pretty',
options: {
translateTime: 'HH:MM:ss Z',
ignore: 'pid,hostname',
},
},
},
production: true,
test: false,
};
const f: FastifyInstance = fastify({ logger: envToLogger.development });
>>>>>>> refs/remotes/origin/nigel/functionBlockMessage
process.on('SIGTERM', () => {
f.log.warn('Requested to shutdown');
process.exit(134);

View file

@ -41,6 +41,41 @@ interface ClientInfo {
lastSeen: number;
}
<<<<<<< HEAD
=======
export type blockedUnBlocked =
{
userState: string,
userTarget: string,
by: string,
};
export type obj =
{
command: string,
destination: string,
type: string,
user: string,
frontendUserName: string,
frontendUser: string,
token: string,
text: string,
timestamp: number,
SenderWindowID: string,
Sendertext: string,
};
// function setAboutPlayer(about: string): string {
// if (!about) {
// about = 'Player is good Shape - This is a default description';
// }
// return about;
// };
>>>>>>> refs/remotes/origin/nigel/functionBlockMessage
export type blockedUnBlocked =
{
@ -174,6 +209,7 @@ async function onReady(fastify: FastifyInstance) {
<<<<<<< HEAD
// fastify.io.fetchSockets().then((sockets) => {
// for (const socket of sockets) {
// const clientInfo = clientChat.get(socket.id);
@ -189,6 +225,23 @@ async function onReady(fastify: FastifyInstance) {
// }
// });
=======
fastify.io.fetchSockets().then((sockets) => {
for (const socket of sockets) {
const clientInfo = clientChat.get(socket.id);
if (!clientInfo?.user) {
console.log(color.yellow, `Skipping socket ${socket.id} (no user found)`);
continue;
}
console.log('DEBUG: UserIDWindow :', getUserByName(users, clientInfo.user)?.id);
const IDUser = getUserByName(users, clientInfo.user)?.id;
console.log(filter_Blocked_user(fastify, obj, IDUser?? ""));
}
});
>>>>>>> refs/remotes/origin/nigel/functionBlockMessage

View file

@ -1,6 +1,7 @@
import type { ClientMessage } from './chat_types';
import { clientChat, color } from './app';
import { FastifyInstance } from 'fastify';
<<<<<<< HEAD
import type { BlockedData } from '@shared/database/mixin/blocked';
import { getUserByName } from './getUserByName';
import type { User } from '@shared/database/mixin/user';
@ -30,6 +31,9 @@ function whoBlockedMe(
=======
import { getUserById } from './getUserById';
>>>>>>> refs/remotes/origin/nigel/functionBlockMessage
export function broadcast(fastify: FastifyInstance, data: ClientMessage, sender?: string) {

View file

@ -32,6 +32,7 @@ export type ClientProfil = {
innerHtml?: string,
};
<<<<<<< HEAD
export type obj =
@ -48,3 +49,5 @@ export type obj =
SenderWindowID: string,
Sendertext: string,
};
=======
>>>>>>> refs/remotes/origin/nigel/functionBlockMessage

View file

@ -4,11 +4,29 @@ import fastify, { FastifyInstance } from 'fastify';
import app from './app';
const start = async () => {
<<<<<<< HEAD
const f: FastifyInstance = fastify({ logger: { level: 'info' } });
process.on('SIGTERM', () => {
f.log.warn('Requested to shutdown');
process.exit(134);
});
=======
const envToLogger = {
development: {
transport: {
target: 'pino-pretty',
options: {
translateTime: 'HH:MM:ss Z',
ignore: 'pid,hostname',
},
},
},
production: true,
test: false,
};
const f: FastifyInstance = fastify({ logger: envToLogger.development });
>>>>>>> refs/remotes/origin/nigel/functionBlockMessage
try {
await f.register(app, {});
await f.listen({ port: 80, host: '0.0.0.0' });

View file

@ -4,7 +4,25 @@ import fastify, { FastifyInstance } from 'fastify';
import app from './app';
const start = async () => {
<<<<<<< HEAD
const f: FastifyInstance = fastify({ logger: { level: 'info' } });
=======
const envToLogger = {
development: {
transport: {
target: 'pino-pretty',
options: {
translateTime: 'HH:MM:ss Z',
ignore: 'pid,hostname',
},
},
},
production: true,
test: false,
};
const f: FastifyInstance = fastify({ logger: envToLogger.development });
>>>>>>> refs/remotes/origin/nigel/functionBlockMessage
process.on('SIGTERM', () => {
f.log.warn('Requested to shutdown');
process.exit(134);