diff options
author | MinusGix <MinusGix@gmail.com> | 2020-03-05 17:49:25 +0100 |
---|---|---|
committer | MinusGix <MinusGix@gmail.com> | 2020-03-05 17:49:25 +0100 |
commit | 50737bc0d9c1ae806610e76be013eeddca1bf102 (patch) | |
tree | daf36b87a9863a798d201242d0bbc68d39cda56d /server/src/commands/admin | |
parent | Make join apply UAC levels to sockets and userInfo (diff) | |
download | hackchat-50737bc0d9c1ae806610e76be013eeddca1bf102.tar.gz hackchat-50737bc0d9c1ae806610e76be013eeddca1bf102.zip |
Move most uses of uType filtering to use UAC levels
Diffstat (limited to '')
-rw-r--r-- | server/src/commands/admin/addmod.js | 7 | ||||
-rw-r--r-- | server/src/commands/admin/listusers.js | 4 | ||||
-rw-r--r-- | server/src/commands/admin/reload.js | 14 | ||||
-rw-r--r-- | server/src/commands/admin/removemod.js | 7 | ||||
-rw-r--r-- | server/src/commands/admin/saveconfig.js | 14 | ||||
-rw-r--r-- | server/src/commands/admin/shout.js | 4 |
6 files changed, 26 insertions, 24 deletions
diff --git a/server/src/commands/admin/addmod.js b/server/src/commands/admin/addmod.js index 26cec40..e5d8495 100644 --- a/server/src/commands/admin/addmod.js +++ b/server/src/commands/admin/addmod.js @@ -2,10 +2,12 @@ Description: Adds the target trip to the mod list then elevates the uType */ +import * as UAC from "../utility/UAC/info"; + // module main export async function run(core, server, socket, data) { // increase rate limit chance and ignore if not admin - if (socket.uType !== 'admin') { + if (!UAC.isAdmin(socket.level)) { return server.police.frisk(socket.address, 20); } @@ -18,6 +20,7 @@ export async function run(core, server, socket, data) { for (let i = 0, l = newMod.length; i < l; i += 1) { // upgrade privilages newMod[i].uType = 'mod'; + newMod[i].level = UAC.levels.moderator; // inform new mod server.send({ @@ -37,7 +40,7 @@ export async function run(core, server, socket, data) { server.broadcast({ cmd: 'info', text: `Added mod: ${data.trip}`, - }, { uType: 'mod' }); + }, { level: UAC.isModerator }); return true; } diff --git a/server/src/commands/admin/listusers.js b/server/src/commands/admin/listusers.js index 0b0199f..3ab6811 100644 --- a/server/src/commands/admin/listusers.js +++ b/server/src/commands/admin/listusers.js @@ -2,10 +2,12 @@ Description: Outputs all current channels and their user nicks */ +import * as UAC from "../utility/UAC/info"; + // module main export async function run(core, server, socket) { // increase rate limit chance and ignore if not admin - if (socket.uType !== 'admin') { + if (!UAC.isAdmin(socket.level)) { return server.police.frisk(socket.address, 20); } diff --git a/server/src/commands/admin/reload.js b/server/src/commands/admin/reload.js index 206e2ca..ccab805 100644 --- a/server/src/commands/admin/reload.js +++ b/server/src/commands/admin/reload.js @@ -2,10 +2,12 @@ Description: Clears and resets the command modules, outputting any errors */ +import * as UAC from "../utility/UAC/info"; + // module main export async function run(core, server, socket, data) { // increase rate limit chance and ignore if not admin - if (socket.uType !== 'admin') { + if (!UAC.isAdmin(socket.level)) { return server.police.frisk(socket.address, 20); } @@ -28,17 +30,11 @@ export async function run(core, server, socket, data) { loadResult += `\nReason: ${data.reason}`; } - // reply with results + // send results to moderators (which the user using this command is higher than) server.reply({ cmd: 'info', text: loadResult, - }, socket); - - // notify mods of reload #transparency - server.broadcast({ - cmd: 'info', - text: loadResult, - }, { uType: 'mod' }); + }, { level: UAC.isModerator }); return true; } diff --git a/server/src/commands/admin/removemod.js b/server/src/commands/admin/removemod.js index 9190dd6..48e65fb 100644 --- a/server/src/commands/admin/removemod.js +++ b/server/src/commands/admin/removemod.js @@ -2,10 +2,12 @@ Description: Removes target trip from the config as a mod and downgrades the socket type */ +import * as UAC from "../utility/UAC/info"; + // module main export async function run(core, server, socket, data) { // increase rate limit chance and ignore if not admin - if (socket.uType !== 'admin') { + if (!UAC.isAdmin(socket.level)) { return server.police.frisk(socket.address, 20); } @@ -18,6 +20,7 @@ export async function run(core, server, socket, data) { for (let i = 0, l = targetMod.length; i < l; i += 1) { // downgrade privilages targetMod[i].uType = 'user'; + targetMod[i].level = UAC.levels.user; // inform ex-mod server.send({ @@ -39,7 +42,7 @@ export async function run(core, server, socket, data) { server.broadcast({ cmd: 'info', text: `Removed mod: ${data.trip}`, - }, { uType: 'mod' }); + }, { level: UAC.isModerator }); return true; } diff --git a/server/src/commands/admin/saveconfig.js b/server/src/commands/admin/saveconfig.js index 6c713b4..708f406 100644 --- a/server/src/commands/admin/saveconfig.js +++ b/server/src/commands/admin/saveconfig.js @@ -2,10 +2,12 @@ Description: Writes the current config to disk */ +import * as UAC from "../utility/UAC/info"; + // module main export async function run(core, server, socket) { // increase rate limit chance and ignore if not admin - if (socket.uType !== 'admin') { + if (!UAC.isAdmin(socket.level)) { return server.police.frisk(socket.address, 20); } @@ -17,17 +19,11 @@ export async function run(core, server, socket) { }, socket); } - // return success message + // return success message to moderators and admins server.reply({ cmd: 'info', text: 'Config saved!', - }, socket); - - // notify mods #transparency - server.broadcast({ - cmd: 'info', - text: 'Config saved!', - }, { uType: 'mod' }); + }, { level: UAC.isModerator }); return true; } diff --git a/server/src/commands/admin/shout.js b/server/src/commands/admin/shout.js index 73b0734..ee81e58 100644 --- a/server/src/commands/admin/shout.js +++ b/server/src/commands/admin/shout.js @@ -2,10 +2,12 @@ Description: Emmits a server-wide message as `info` */ +import * as UAC from "../utility/UAC/info"; + // module main export async function run(core, server, socket, data) { // increase rate limit chance and ignore if not admin - if (socket.uType !== 'admin') { + if (!UAC.isAdmin(socket.level)) { return server.police.frisk(socket.address, 20); } |