mirror of https://github.com/calzoneman/sync.git
Clamp timeouts to 1 day
This commit is contained in:
parent
2a1f1df17b
commit
60c348a905
|
@ -2,7 +2,7 @@
|
||||||
"author": "Calvin Montgomery",
|
"author": "Calvin Montgomery",
|
||||||
"name": "CyTube",
|
"name": "CyTube",
|
||||||
"description": "Online media synchronizer and chat",
|
"description": "Online media synchronizer and chat",
|
||||||
"version": "3.65.0",
|
"version": "3.65.1",
|
||||||
"repository": {
|
"repository": {
|
||||||
"url": "http://github.com/calzoneman/sync"
|
"url": "http://github.com/calzoneman/sync"
|
||||||
},
|
},
|
||||||
|
|
|
@ -59,6 +59,7 @@ OptionsModule.prototype.load = function (data) {
|
||||||
10,
|
10,
|
||||||
this.opts.chat_antiflood_params.sustained
|
this.opts.chat_antiflood_params.sustained
|
||||||
);
|
);
|
||||||
|
this.opts.afk_timeout = Math.min(86400 /* one day */, this.opts.afk_timeout);
|
||||||
this.dirty = false;
|
this.dirty = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -139,9 +140,16 @@ OptionsModule.prototype.handleSetOptions = function (user, data) {
|
||||||
|
|
||||||
if ("afk_timeout" in data) {
|
if ("afk_timeout" in data) {
|
||||||
var tm = parseInt(data.afk_timeout);
|
var tm = parseInt(data.afk_timeout);
|
||||||
if (isNaN(tm) || tm < 0) {
|
if (isNaN(tm) || tm < 0 || tm > 86400 /* one day */) {
|
||||||
tm = 0;
|
tm = 0;
|
||||||
}
|
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;
|
var same = tm === this.opts.afk_timeout;
|
||||||
this.opts.afk_timeout = tm;
|
this.opts.afk_timeout = tm;
|
||||||
|
@ -152,6 +160,7 @@ OptionsModule.prototype.handleSetOptions = function (user, data) {
|
||||||
}
|
}
|
||||||
sendUpdate = true;
|
sendUpdate = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ("pagetitle" in data && user.account.effectiveRank >= 3) {
|
if ("pagetitle" in data && user.account.effectiveRank >= 3) {
|
||||||
var title = unzalgo((""+data.pagetitle).substring(0, 100));
|
var title = unzalgo((""+data.pagetitle).substring(0, 100));
|
||||||
|
|
|
@ -187,9 +187,19 @@ PollModule.prototype.handleNewPoll = function (user, data, ack) {
|
||||||
return;
|
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 poll = new Poll(user.getName(), data.title, data.opts, data.obscured);
|
||||||
var self = this;
|
var self = this;
|
||||||
if (data.hasOwnProperty("timeout") && !isNaN(data.timeout) && data.timeout > 0) {
|
if (data.hasOwnProperty("timeout")) {
|
||||||
poll.timer = setTimeout(function () {
|
poll.timer = setTimeout(function () {
|
||||||
if (self.poll === poll) {
|
if (self.poll === poll) {
|
||||||
self.handleClosePoll({
|
self.handleClosePoll({
|
||||||
|
|
Loading…
Reference in New Issue