Skip to content

Commit

Permalink
Merge pull request hack-chat#98 from MinusGix/BanMinor
Browse files Browse the repository at this point in the history
More verbose ban event + UAC getUserDetails additions
  • Loading branch information
marzavec authored Mar 16, 2020
2 parents 485a37c + fb234bb commit be310af
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions server/src/commands/mod/ban.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions server/src/commands/utility/UAC/_info.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit be310af

Please sign in to comment.