From e35fff59ba30e78046c9212e74fce9aef56c6e93 Mon Sep 17 00:00:00 2001 From: marzavec Date: Mon, 4 Jun 2018 00:07:24 -0700 Subject: cleaned up and commented modules --- server/src/commands/admin/addmod.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'server/src/commands/admin/addmod.js') diff --git a/server/src/commands/admin/addmod.js b/server/src/commands/admin/addmod.js index 4c13b22..bde54a1 100644 --- a/server/src/commands/admin/addmod.js +++ b/server/src/commands/admin/addmod.js @@ -3,19 +3,18 @@ */ exports.run = async (core, server, socket, data) => { + // increase rate limit chance and ignore if not admin if (socket.uType != 'admin') { - // ignore if not admin - return; - } + server._police.frisk(socket.remoteAddress, 20); - let mod = { - trip: data.trip + return; } - core.config.mods.push(mod); // purposely not using `config.set()` to avoid auto-save + // add new trip to config + core.config.mods.push({ trip: data.trip }); // purposely not using `config.set()` to avoid auto-save + // upgarde existing connections & notify user let newMod = server.findSockets({ trip: data.trip }); - if (newMod.length !== 0) { for (let i = 0, l = newMod.length; i < l; i++) { newMod[i].uType = 'mod'; @@ -27,11 +26,13 @@ exports.run = async (core, server, socket, data) => { } } + // return success message server.reply({ cmd: 'info', text: `Added mod trip: ${data.trip}` }, socket); + // notify all mods server.broadcast({ cmd: 'info', text: `Added mod trip: ${data.trip}` -- cgit v1.2.1