Clamp timeouts to 1 day
This commit is contained in:
parent
2a1f1df17b
commit
60c348a905
|
@ -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"
|
||||
},
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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({
|
||||
|
|
Loading…
Reference in a new issue