Fix setOptions for playlist_max_duration_per_user

This commit is contained in:
Calvin Montgomery 2017-05-20 16:31:52 -07:00
parent 02587dbb5c
commit 55b03d51d7
2 changed files with 7 additions and 19 deletions

View File

@ -2,7 +2,7 @@
"author": "Calvin Montgomery",
"name": "CyTube",
"description": "Online media synchronizer and chat",
"version": "3.36.1",
"version": "3.36.2",
"repository": {
"url": "http://github.com/calzoneman/sync"
},

View File

@ -173,26 +173,14 @@ OptionsModule.prototype.handleSetOptions = function (user, data) {
}
if ("playlist_max_duration_per_user" in data) {
const rawMax = data.playlist_max_duration_per_user;
if (typeof rawMax !== "string" || !rawMax.match(/^(\d+:)*\d+$/)) {
user.socket.emit("validationError", {
target: "#cs-playlist_max_duration_per_user",
message: `Input must be a time in the format HH:MM:SS, not "${rawMax}"`
const max = data.playlist_max_duration_per_user;
if (typeof max !== "number" || isNaN(max) || max < 0) {
user.socket.emit("errorMsg", {
msg: `Expected number for playlist_max_duration_per_user, not "${max}"`
});
} else {
const max = Utilities.parseTime(rawMax);
if (isNaN(max) || max < 0) {
user.socket.emit("validationError", {
target: "#cs-playlist_max_duration_per_user",
message: `Input must be a time greater than 0 in the format HH:MM:SS, not "${rawMax}"`
});
} else {
this.opts.playlist_max_duration_per_user = max;
sendUpdate = true;
user.socket.emit("validationPassed", {
target: "#cs-playlist_max_duration_per_user"
});
}
this.opts.playlist_max_duration_per_user = max;
sendUpdate = true;
}
}