Added cmd @block <name> to toggle block / un block user

This commit is contained in:
NigeParis 2026-01-06 15:26:43 +01:00 committed by Maix0
parent 0ef66cdc10
commit 97a7384af7
4 changed files with 38 additions and 6 deletions

View file

@ -132,11 +132,11 @@ services:
- JWT_SECRET=KRUGKIDROVUWG2ZAMJZG653OEBTG66BANJ2W24DTEBXXMZLSEB2GQZJANRQXU6JA
- PROVIDER_FILE=/extra/providers.toml
- SESSION_MANAGER=${SESSION_MANAGER}
logging:
driver: gelf
options:
gelf-address: "udp://127.0.0.1:12201"
tag: "{{.Name}}"
# logging:
# driver: gelf
# options:
# gelf-address: "udp://127.0.0.1:12201"
# tag: "{{.Name}}"
###############
# PONG #

View file

@ -14,9 +14,11 @@ import { openProfilePopup } from './chatHelperFunctions/openProfilePopup';
import { actionBtnPopUpBlock } from './chatHelperFunctions/actionBtnPopUpBlock';
import { windowStateHidden } from './chatHelperFunctions/windowStateHidden';
import type { blockedUnBlocked, obj } from './types_front';
import { blockUser } from './chatHelperFunctions/blockUser';
const MAX_SYSTEM_MESSAGES = 10;
let inviteMsgFlag: boolean = false;
export let noGuestFlag: boolean = false;
const machineHostName = window.location.hostname;
export let __socket: Socket | undefined = undefined;
@ -389,6 +391,7 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn
// Send button
sendButton?.addEventListener("click", () => {
const notify = document.getElementById("notify") ?? null;
const noGuest = document.getElementById("guestMsg") ?? null;
if (sendtextbox && sendtextbox.value.trim()) {
let msgText: string = sendtextbox.value.trim();
const msgCommand = parseCmdMsg(msgText) ?? "";
@ -398,6 +401,30 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn
case '@msg':
broadcastMsg(socket, msgCommand);
break;
case '@block':
if (msgCommand[1] === '') {break;};
const userAskingToBlock = getUser()?.name;
if (!userAskingToBlock) return;
const userID1 = getUser()?.id;
if (!userID1) return;
const userToBlock: ClientProfil = {
command: msgCommand[0],
destination: '',
type: 'chat',
user: msgCommand[1],
loginName: '',
userID: userID1,
text: '',
timestamp: Date.now(),
SenderWindowID: '',
SenderName: userAskingToBlock,
SenderID: '',
Sendertext: '',
innerHtml: '',
}
blockUser(userToBlock, socket);
break;
case '@notify':
if (notify === null) {break;};
if (inviteMsgFlag === false) {
@ -420,6 +447,7 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn
addMessage('** ********** List of @cmds ********** **');
addMessage('\'@cls\' - clear chat screen conversations');
addMessage('\'@profile <name>\' - pulls ups user profile');
addMessage('\'@block <name>\' - blocks / unblock user');
addMessage('\'@notify\' - toggles notifications on / off');
addMessage('\'@quit\' - disconnect user from the chat');
addMessage('** *********************************** **');

View file

@ -2,6 +2,7 @@ import { addMessage } from "./addMessage";
import { Socket } from 'socket.io-client';
import { getUser } from "@app/auth";
import type { ClientMessage } from "../types_front";
import { noGuestFlag } from "../chat";
/**
* function sends socket.emit to the backend to active and broadcast a message to all sockets
* echos the message with addMessage to the sender
@ -10,6 +11,7 @@ import type { ClientMessage } from "../types_front";
*/
export function broadcastMsg (socket: Socket, msgCommand: string[]): void {
let msgText = msgCommand[1] ?? "";
let dest = '';
addMessage(msgText);
const user = getUser();
if (user && socket?.connected) {

View file

@ -374,6 +374,8 @@ async function onReady(fastify: FastifyInstance) {
}
}
});
socket.on('client_entered', (data) => {
// data may be undefined (when frontend calls emit with no payload)