From 713f00f99f8ba13a825cedf632e86e7364e7f540 Mon Sep 17 00:00:00 2001 From: MinusGix Date: Mon, 16 Mar 2020 10:29:16 -0500 Subject: Add command to get information about users to broadcast to clients --- server/src/commands/utility/UAC/_info.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/server/src/commands/utility/UAC/_info.js b/server/src/commands/utility/UAC/_info.js index c5010a6..7981afc 100644 --- a/server/src/commands/utility/UAC/_info.js +++ b/server/src/commands/utility/UAC/_info.js @@ -90,6 +90,23 @@ export function isTrustedUser(level) { return level >= levels.trustedUser; } +/** + * Return an object containing public information about the socket + * @public + * @param {WebSocket} socket Target client + * @return {Object} + */ +export function getUserDetails(socket) { + return { + uType: socket.uType, + nick: socket.nick, + trip: socket.trip || 'null', + hash: socket.hash, + level: socket.level, + userid: socket.userid, + }; +} + /** * Returns true if the nickname is valid * @public -- cgit v1.2.1 From fb234bbaa7e4f3edb6fc8a5281818bda5cd367b4 Mon Sep 17 00:00:00 2001 From: MinusGix Date: Mon, 16 Mar 2020 10:29:42 -0500 Subject: Make ban command broadcast information about user and banner --- server/src/commands/mod/ban.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/src/commands/mod/ban.js b/server/src/commands/mod/ban.js index b33b55e..994bc1c 100644 --- a/server/src/commands/mod/ban.js +++ b/server/src/commands/mod/ban.js @@ -46,12 +46,16 @@ export async function run(core, server, socket, data) { server.broadcast({ cmd: 'info', text: `Banned ${targetNick}`, + user: UAC.getUserDetails(badClient), }, { channel: socket.channel, level: (level) => level < UAC.levels.moderator }); // notify mods server.broadcast({ cmd: 'info', text: `${socket.nick}#${socket.trip} banned ${targetNick} in ${socket.channel}, userhash: ${badClient.hash}`, + channel: socket.channel, + user: UAC.getUserDetails(badClient), + banner: UAC.getUserDetails(socket), }, { level: UAC.isModerator }); // force connection closed -- cgit v1.2.1