Added cmd @block <name> to toggle block / un block user
This commit is contained in:
parent
0ef66cdc10
commit
97a7384af7
4 changed files with 38 additions and 6 deletions
|
|
@ -132,11 +132,11 @@ services:
|
||||||
- JWT_SECRET=KRUGKIDROVUWG2ZAMJZG653OEBTG66BANJ2W24DTEBXXMZLSEB2GQZJANRQXU6JA
|
- JWT_SECRET=KRUGKIDROVUWG2ZAMJZG653OEBTG66BANJ2W24DTEBXXMZLSEB2GQZJANRQXU6JA
|
||||||
- PROVIDER_FILE=/extra/providers.toml
|
- PROVIDER_FILE=/extra/providers.toml
|
||||||
- SESSION_MANAGER=${SESSION_MANAGER}
|
- SESSION_MANAGER=${SESSION_MANAGER}
|
||||||
logging:
|
# logging:
|
||||||
driver: gelf
|
# driver: gelf
|
||||||
options:
|
# options:
|
||||||
gelf-address: "udp://127.0.0.1:12201"
|
# gelf-address: "udp://127.0.0.1:12201"
|
||||||
tag: "{{.Name}}"
|
# tag: "{{.Name}}"
|
||||||
|
|
||||||
###############
|
###############
|
||||||
# PONG #
|
# PONG #
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,11 @@ import { openProfilePopup } from './chatHelperFunctions/openProfilePopup';
|
||||||
import { actionBtnPopUpBlock } from './chatHelperFunctions/actionBtnPopUpBlock';
|
import { actionBtnPopUpBlock } from './chatHelperFunctions/actionBtnPopUpBlock';
|
||||||
import { windowStateHidden } from './chatHelperFunctions/windowStateHidden';
|
import { windowStateHidden } from './chatHelperFunctions/windowStateHidden';
|
||||||
import type { blockedUnBlocked, obj } from './types_front';
|
import type { blockedUnBlocked, obj } from './types_front';
|
||||||
|
import { blockUser } from './chatHelperFunctions/blockUser';
|
||||||
|
|
||||||
const MAX_SYSTEM_MESSAGES = 10;
|
const MAX_SYSTEM_MESSAGES = 10;
|
||||||
let inviteMsgFlag: boolean = false;
|
let inviteMsgFlag: boolean = false;
|
||||||
|
export let noGuestFlag: boolean = false;
|
||||||
const machineHostName = window.location.hostname;
|
const machineHostName = window.location.hostname;
|
||||||
|
|
||||||
export let __socket: Socket | undefined = undefined;
|
export let __socket: Socket | undefined = undefined;
|
||||||
|
|
@ -389,6 +391,7 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn
|
||||||
// Send button
|
// Send button
|
||||||
sendButton?.addEventListener("click", () => {
|
sendButton?.addEventListener("click", () => {
|
||||||
const notify = document.getElementById("notify") ?? null;
|
const notify = document.getElementById("notify") ?? null;
|
||||||
|
const noGuest = document.getElementById("guestMsg") ?? null;
|
||||||
if (sendtextbox && sendtextbox.value.trim()) {
|
if (sendtextbox && sendtextbox.value.trim()) {
|
||||||
let msgText: string = sendtextbox.value.trim();
|
let msgText: string = sendtextbox.value.trim();
|
||||||
const msgCommand = parseCmdMsg(msgText) ?? "";
|
const msgCommand = parseCmdMsg(msgText) ?? "";
|
||||||
|
|
@ -398,6 +401,30 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn
|
||||||
case '@msg':
|
case '@msg':
|
||||||
broadcastMsg(socket, msgCommand);
|
broadcastMsg(socket, msgCommand);
|
||||||
break;
|
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':
|
case '@notify':
|
||||||
if (notify === null) {break;};
|
if (notify === null) {break;};
|
||||||
if (inviteMsgFlag === false) {
|
if (inviteMsgFlag === false) {
|
||||||
|
|
@ -420,6 +447,7 @@ function handleChat(_url: string, _args: RouteHandlerParams): RouteHandlerReturn
|
||||||
addMessage('** ********** List of @cmds ********** **');
|
addMessage('** ********** List of @cmds ********** **');
|
||||||
addMessage('\'@cls\' - clear chat screen conversations');
|
addMessage('\'@cls\' - clear chat screen conversations');
|
||||||
addMessage('\'@profile <name>\' - pulls ups user profile');
|
addMessage('\'@profile <name>\' - pulls ups user profile');
|
||||||
|
addMessage('\'@block <name>\' - blocks / unblock user');
|
||||||
addMessage('\'@notify\' - toggles notifications on / off');
|
addMessage('\'@notify\' - toggles notifications on / off');
|
||||||
addMessage('\'@quit\' - disconnect user from the chat');
|
addMessage('\'@quit\' - disconnect user from the chat');
|
||||||
addMessage('** *********************************** **');
|
addMessage('** *********************************** **');
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import { addMessage } from "./addMessage";
|
||||||
import { Socket } from 'socket.io-client';
|
import { Socket } from 'socket.io-client';
|
||||||
import { getUser } from "@app/auth";
|
import { getUser } from "@app/auth";
|
||||||
import type { ClientMessage } from "../types_front";
|
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
|
* function sends socket.emit to the backend to active and broadcast a message to all sockets
|
||||||
* echos the message with addMessage to the sender
|
* 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 {
|
export function broadcastMsg (socket: Socket, msgCommand: string[]): void {
|
||||||
let msgText = msgCommand[1] ?? "";
|
let msgText = msgCommand[1] ?? "";
|
||||||
|
let dest = '';
|
||||||
addMessage(msgText);
|
addMessage(msgText);
|
||||||
const user = getUser();
|
const user = getUser();
|
||||||
if (user && socket?.connected) {
|
if (user && socket?.connected) {
|
||||||
|
|
|
||||||
|
|
@ -374,6 +374,8 @@ async function onReady(fastify: FastifyInstance) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
socket.on('client_entered', (data) => {
|
socket.on('client_entered', (data) => {
|
||||||
|
|
||||||
// data may be undefined (when frontend calls emit with no payload)
|
// data may be undefined (when frontend calls emit with no payload)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue