From d93e42a71c480428b26bac4092d3de64c83d3726 Mon Sep 17 00:00:00 2001 From: zeratul0 Date: Mon, 6 Mar 2017 13:44:05 -0500 Subject: [PATCH 1/3] Change fallback voteskip ratio to .5 from 0 moderators might make a mistake changing the skip ratio, causing it to fall back to 0% and allowing users to "skiptrain" before it is fixed --- src/channel/opts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/channel/opts.js b/src/channel/opts.js index c4d33612..9802a807 100644 --- a/src/channel/opts.js +++ b/src/channel/opts.js @@ -114,7 +114,7 @@ OptionsModule.prototype.handleSetOptions = function (user, data) { if ("voteskip_ratio" in data) { var ratio = parseFloat(data.voteskip_ratio); if (isNaN(ratio) || ratio < 0) { - ratio = 0; + ratio = 0.5; } this.opts.voteskip_ratio = ratio; sendUpdate = true; From ab1358df365df6c8997c14cdf1142f0b57346847 Mon Sep 17 00:00:00 2001 From: zeratul0 Date: Thu, 16 Mar 2017 18:35:42 -0400 Subject: [PATCH 2/3] Change skipratio fallback to error response --- src/channel/opts.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/channel/opts.js b/src/channel/opts.js index 9802a807..eef38dd2 100644 --- a/src/channel/opts.js +++ b/src/channel/opts.js @@ -114,10 +114,17 @@ OptionsModule.prototype.handleSetOptions = function (user, data) { if ("voteskip_ratio" in data) { var ratio = parseFloat(data.voteskip_ratio); if (isNaN(ratio) || ratio < 0) { - ratio = 0.5; + user.socket.emit("validationError", { + target: "#cs-voteskip_ratio", + message: "Input must be a number 0 or greater. 1.0 is 100%." + }); + } else { + this.opts.voteskip_ratio = ratio; + sendUpdate = true; + user.socket.emit("validationPassed", { + target: "#cs-voteskip_ratio" + }); } - this.opts.voteskip_ratio = ratio; - sendUpdate = true; } if ("afk_timeout" in data) { From 88044e11d5774d1548948b948783fdee17b4b0e9 Mon Sep 17 00:00:00 2001 From: zeratul0 Date: Thu, 16 Mar 2017 23:34:38 -0400 Subject: [PATCH 3/3] Error response -> template literal as requested --- src/channel/opts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/channel/opts.js b/src/channel/opts.js index eef38dd2..46da8a83 100644 --- a/src/channel/opts.js +++ b/src/channel/opts.js @@ -116,7 +116,7 @@ OptionsModule.prototype.handleSetOptions = function (user, data) { if (isNaN(ratio) || ratio < 0) { user.socket.emit("validationError", { target: "#cs-voteskip_ratio", - message: "Input must be a number 0 or greater. 1.0 is 100%." + message: `Input must be a number 0 or greater, not "${data.voteskip_ratio}"` }); } else { this.opts.voteskip_ratio = ratio;