From b0ff4d5ef0d6a7e99af59ed350dc7ee18327c199 Mon Sep 17 00:00:00 2001 From: Calvin Montgomery Date: Mon, 23 Jan 2017 21:16:39 -0800 Subject: [PATCH] Make delete from channel library a configurable permission --- package.json | 2 +- src/channel/permissions.js | 12 +++++------- www/js/callbacks.js | 2 +- www/js/util.js | 3 ++- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 017f6b4a..6dc2b27e 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "Calvin Montgomery", "name": "CyTube", "description": "Online media synchronizer and chat", - "version": "3.28.0", + "version": "3.28.1", "repository": { "url": "http://github.com/calzoneman/sync" }, diff --git a/src/channel/permissions.js b/src/channel/permissions.js index 12df2800..d85774b8 100644 --- a/src/channel/permissions.js +++ b/src/channel/permissions.js @@ -41,7 +41,8 @@ const DEFAULT_PERMISSIONS = { drink: 1.5, // Use the /d command chat: 0, // Send chat messages chatclear: 2, // Use the /clear command - exceedmaxitems: 2 // Exceed maximum items per user limit + exceedmaxitems: 2, // Exceed maximum items per user limit + deletefromchannellib: 2 // Delete channel library items }; function PermissionsModule(channel) { @@ -336,11 +337,7 @@ PermissionsModule.prototype.canSetPermissions = function (actor) { }; PermissionsModule.prototype.canUncache = function (actor) { - if (actor instanceof User) { - actor = actor.account; - } - - return actor.effectiveRank >= 2; + return this.hasPermission(actor, "deletefromchannellib"); }; PermissionsModule.prototype.canExceedMaxItemsPerUser = function (actor) { @@ -379,7 +376,8 @@ PermissionsModule.prototype.loadUnregistered = function () { drink: 0, // Use the /d command chat: 0, // Send chat messages chatclear: 2, // Use the /clear command - exceedmaxitems: 2 // Exceed max items per user + exceedmaxitems: 2, // Exceed max items per user + deletefromchannellib: 2 }; for (var key in perms) { diff --git a/www/js/callbacks.js b/www/js/callbacks.js index d9b54c0b..025fce2b 100644 --- a/www/js/callbacks.js +++ b/www/js/callbacks.js @@ -893,7 +893,7 @@ Callbacks = { generator: function (item, page, index) { var li = makeSearchEntry(item, false); - if(hasPermission("playlistadd")) { + if(hasPermission("playlistadd") || hasPermission("deletefromchannellib")) { addLibraryButtons(li, item.id, data.source); } $(li).appendTo($("#library")); diff --git a/www/js/util.js b/www/js/util.js index f9c3429a..095f8829 100644 --- a/www/js/util.js +++ b/www/js/util.js @@ -1121,7 +1121,7 @@ function addLibraryButtons(li, id, source) { }) .appendTo(btns); } - if(CLIENT.rank >= 2 && source === "library") { + if(hasPermission("deletefromchannellib") && source === "library") { $("