From 33f4ffcec256f3b4253ab5ce160a1f8c91b7b5cd Mon Sep 17 00:00:00 2001 From: Calvin Montgomery Date: Tue, 4 Jun 2013 22:51:41 -0400 Subject: [PATCH] Add permission option for livestreams --- channel.js | 7 ++++++- www/assets/js/callbacks.js | 7 +++++-- www/assets/js/functions.js | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/channel.js b/channel.js index aa4b60e4..1c749da6 100644 --- a/channel.js +++ b/channel.js @@ -55,7 +55,7 @@ var Channel = function(name) { playlistdelete: 2, playlistjump: 1.5, playlistaddlist: 1.5, - playlistadd: 1.5, + playlistaddlive: 1.5, addnontemp: 2, settemp: 2, playlistgeturl: 1.5, @@ -985,6 +985,11 @@ Channel.prototype.autoTemp = function(media, user) { Channel.prototype.enqueue = function(data, user) { var idx = data.pos == "next" ? this.position + 1 : this.queue.length; + if(isLive(data.type) && !this.hasPermission(user, "playlistaddlive")) { + user.socket.emit("queueFail", "You don't have permission to queue livestreams"); + return; + } + // Prefer cache over looking up new data if(data.id in this.library) { var media = this.library[data.id].dup(); diff --git a/www/assets/js/callbacks.js b/www/assets/js/callbacks.js index 3396ed7b..8680b4e1 100644 --- a/www/assets/js/callbacks.js +++ b/www/assets/js/callbacks.js @@ -581,8 +581,11 @@ Callbacks = { $(li).show("blind"); }, - queueFail: function() { - makeAlert("Error", "Queue failed. Check your link to make sure it is valid.", "alert-error") + queueFail: function(data) { + if(!data) { + data = "Queue failed. Check your link to make sure it is valid."; + } + makeAlert("Error", data, "alert-error") .insertAfter($("#playlist_controls")); }, diff --git a/www/assets/js/functions.js b/www/assets/js/functions.js index e13310cf..135ab045 100644 --- a/www/assets/js/functions.js +++ b/www/assets/js/functions.js @@ -1314,6 +1314,7 @@ function genPermissionsEditor() { makeOption("Delete playlist items", "playlistdelete", standard, CHANPERMS.playlistdelete+""); makeOption("Jump to video", "playlistjump", standard, CHANPERMS.playlistjump+""); makeOption("Queue playlist", "playlistaddlist", standard, CHANPERMS.playlistaddlist+""); + makeOption("Queue livestream", "playlistaddlive", standard, CHANPERMS.playlistaddlive+""); makeOption("Add nontemporary media", "addnontemp", standard, CHANPERMS.addnontemp+""); makeOption("Temp/untemp playlist item", "settemp", standard, CHANPERMS.settemp+""); makeOption("Retrieve playlist URLs", "playlistgeturl", standard, CHANPERMS.playlistgeturl+"");