Continued work on media schedule panel.
This commit is contained in:
parent
d5a2a51be2
commit
90be85de26
6 changed files with 475 additions and 103 deletions
|
|
@ -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 <https://www.gnu.org/licenses/>.*/
|
||||
|
||||
//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){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue