diff --git a/package.json b/package.json index b7581090..d2e69761 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "Calvin Montgomery", "name": "CyTube", "description": "Online media synchronizer and chat", - "version": "3.65.0", + "version": "3.65.1", "repository": { "url": "http://github.com/calzoneman/sync" }, diff --git a/src/channel/opts.js b/src/channel/opts.js index 29a12dc9..500cd5d6 100644 --- a/src/channel/opts.js +++ b/src/channel/opts.js @@ -59,6 +59,7 @@ OptionsModule.prototype.load = function (data) { 10, this.opts.chat_antiflood_params.sustained ); + this.opts.afk_timeout = Math.min(86400 /* one day */, this.opts.afk_timeout); this.dirty = false; }; @@ -139,18 +140,26 @@ OptionsModule.prototype.handleSetOptions = function (user, data) { if ("afk_timeout" in data) { var tm = parseInt(data.afk_timeout); - if (isNaN(tm) || tm < 0) { + if (isNaN(tm) || tm < 0 || tm > 86400 /* one day */) { tm = 0; - } - - var same = tm === this.opts.afk_timeout; - this.opts.afk_timeout = tm; - if (!same) { - this.channel.users.forEach(function (u) { - u.autoAFK(); + user.socket.emit("validationError", { + target: "#cs-afk_timeout", + message: "AFK timeout must be between 1 and 86400 seconds (or 0 to disable)" }); + } else { + user.socket.emit("validationPassed", { + target: "#cs-afk_timeout", + }); + + var same = tm === this.opts.afk_timeout; + this.opts.afk_timeout = tm; + if (!same) { + this.channel.users.forEach(function (u) { + u.autoAFK(); + }); + } + sendUpdate = true; } - sendUpdate = true; } if ("pagetitle" in data && user.account.effectiveRank >= 3) { diff --git a/src/channel/poll.js b/src/channel/poll.js index c181a7ab..52717e7c 100644 --- a/src/channel/poll.js +++ b/src/channel/poll.js @@ -187,9 +187,19 @@ PollModule.prototype.handleNewPoll = function (user, data, ack) { return; } + if (data.hasOwnProperty("timeout") && + (isNaN(data.timeout) || data.timeout < 1 || data.timeout > 86400)) { + ack({ + error: { + message: "Poll timeout must be between 1 and 86400 seconds" + } + }); + return; + } + var poll = new Poll(user.getName(), data.title, data.opts, data.obscured); var self = this; - if (data.hasOwnProperty("timeout") && !isNaN(data.timeout) && data.timeout > 0) { + if (data.hasOwnProperty("timeout")) { poll.timer = setTimeout(function () { if (self.poll === poll) { self.handleClosePoll({