From 90be85de2609063d8260a5a17b7880b89671162a Mon Sep 17 00:00:00 2001 From: rainbow napkin Date: Sun, 2 Feb 2025 18:49:20 -0500 Subject: [PATCH] Continued work on media schedule panel. --- src/app/channel/media/queue.js | 56 +++- src/views/partial/panels/queue.ejs | 13 +- www/css/panel/queue.css | 31 ++- www/css/theme/movie-night.css | 34 ++- www/js/channel/panels/queuePanel.js | 415 ++++++++++++++++++++++------ www/js/utils.js | 29 +- 6 files changed, 475 insertions(+), 103 deletions(-) diff --git a/src/app/channel/media/queue.js b/src/app/channel/media/queue.js index e591858..7e6b9f2 100644 --- a/src/app/channel/media/queue.js +++ b/src/app/channel/media/queue.js @@ -14,6 +14,9 @@ GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see .*/ +//NPM imports +const validator = require('validator'); + //Local imports const queuedMedia = require('./queuedMedia'); const yanker = require('../../../utils/media/yanker'); @@ -51,8 +54,37 @@ module.exports = class{ async queueURL(socket, data){ try{ + //Set url + const url = encodeURI(data.url); + //pull URL and start time from data - let {url, start, title} = data; + //let {url, start, title} = data; + //If we where given a bad URL + if(!validator.isURL(url)){ + //Bitch, moan, complain... + loggerUtils.socketErrorHandler(socket, "Bad URL!", "validation"); + //and ignore it! + return; + } + + //If the title is too long + if(!validator.isLength(data.title, {max:30})){ + //Bitch, moan, complain... + loggerUtils.socketErrorHandler(socket, "Title too long!", "validation"); + //and ignore it! + return; + } + + //Set title + const title = validator.escape(validator.trim(data.title)); + //set start + var start = data.start; + + //If start time isn't an integer after the current epoch + if(start != null &&!validator.isInt(String(start), (new Date().getTime()))){ + //Null out time to tell the later parts of the function to start it now + start = null; + } //Pull media list const mediaList = await yanker.yankMedia(url, title); @@ -86,6 +118,14 @@ module.exports = class{ deleteMedia(socket, data){ try{ + //If we don't have a valid UUID + if(!validator.isUUID(data.uuid)){ + //Bitch, moan, complain... + loggerUtils.socketErrorHandler(socket, "Bad UUID!", "validation"); + //and ignore it! + return; + } + //Remove media by UUID this.removeMedia(data.uuid, socket); }catch(err){ @@ -95,6 +135,20 @@ module.exports = class{ moveMedia(socket, data){ try{ + //If we don't have a valid UUID + if(!validator.isUUID(data.uuid)){ + //Bitch, moan, complain... + loggerUtils.socketErrorHandler(socket, "Bad UUID!", "validation"); + //and ignore it! + return; + } + + //If start time isn't an integer after the current epoch + if(data.start != null && !validator.isInt(String(data.start), new Date().getTime())){ + //Null out time to tell the later parts of the function to start it now + data.start = null; + } + //Move media by UUID this.rescheduleMedia(data.uuid, data.start, socket); }catch(err){ diff --git a/src/views/partial/panels/queue.ejs b/src/views/partial/panels/queue.ejs index c52e8aa..470ac2b 100644 --- a/src/views/partial/panels/queue.ejs +++ b/src/views/partial/panels/queue.ejs @@ -19,11 +19,16 @@ along with this program. If not, see . %>
+ + - - - - + + +
+