1
0
mirror of https://github.com/hack-chat/main.git synced 2024-03-22 13:20:33 +08:00

Merge pull request #98 from MinusGix/BanMinor

More verbose ban event + UAC getUserDetails additions
This commit is contained in:
marzavec 2020-03-16 10:50:21 -05:00 committed by GitHub
commit be310af3bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View File

@ -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

View File

@ -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