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", "author": "Calvin Montgomery",
"name": "CyTube", "name": "CyTube",
"description": "Online media synchronizer and chat", "description": "Online media synchronizer and chat",
"version": "3.36.1", "version": "3.36.2",
"repository": { "repository": {
"url": "http://github.com/calzoneman/sync" "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) { if ("playlist_max_duration_per_user" in data) {
const rawMax = data.playlist_max_duration_per_user; const max = data.playlist_max_duration_per_user;
if (typeof rawMax !== "string" || !rawMax.match(/^(\d+:)*\d+$/)) { if (typeof max !== "number" || isNaN(max) || max < 0) {
user.socket.emit("validationError", { user.socket.emit("errorMsg", {
target: "#cs-playlist_max_duration_per_user", msg: `Expected number for playlist_max_duration_per_user, not "${max}"`
message: `Input must be a time in the format HH:MM:SS, not "${rawMax}"`
}); });
} else { } else {
const max = Utilities.parseTime(rawMax); this.opts.playlist_max_duration_per_user = max;
if (isNaN(max) || max < 0) { sendUpdate = true;
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"
});
}
} }
} }