WIP - block guests - working - deBugging

This commit is contained in:
NigeParis 2026-01-08 08:39:30 +01:00 committed by Maix0
parent 7178673794
commit 2b9613fbfb
3 changed files with 22 additions and 6 deletions

View file

@ -266,12 +266,17 @@ async function onReady(fastify: FastifyInstance) {
if (profile.guestmsg) {
//console.log('Data TRUE:', clientName);
//console.log(user?.id);
console.log(user?.name);
console.log(user?.guest);
console.log(user?.allow_guest_message);
fastify.db.allowGuestMessage(user?.id);
}
else
{
//console.log('Data FALSE', clientName);
console.log(user?.name);
console.log(user?.guest);
console.log(user?.allow_guest_message);
fastify.db.denyGuestMessage(user?.id);
};
}
@ -409,13 +414,13 @@ async function onReady(fastify: FastifyInstance) {
let text = 'is back in the chat';
if (clientName === null) {
fastify.log.error('ERROR: clientName is NULL'); return;
fastify.log.error('ERROR1: clientName is NULL'); return;
};
if (userNameFromFrontend !== userFromFrontend) {
text = `'is back in the chat, I used to be called '${userNameFromFrontend}`;
clientName = userFromFrontend;
if (clientName === null) {
fastify.log.error('ERROR: clientName is NULL'); return;
fastify.log.error('ERROR2: clientName is NULL'); return;
};
}
if (clientName !== null) {

View file

@ -29,8 +29,12 @@ export async function broadcast(fastify: FastifyInstance, data: ClientMessage, s
}
if (!user?.id) return;
const boolGuestMsg = fastify.db.getGuestMessage(user?.id);
if (boolGuestMsg && user.guest) continue;
const guestflag: User | null = getUserByName(Allusers,clientInfo.user);
if (!guestflag) return;
console.log('G Flag Allow:', guestflag?.allow_guest_message);
console.log('User:', guestflag?.name);
const boolGuestMsg = fastify.db.getGuestMessage(guestflag?.id);
if (!boolGuestMsg) continue;
if (!blockMsgFlag) {
socket.emit('MsgObjectServer', { message: data });