Disallow non-moderators from adding a video that exists 10 times already

This commit is contained in:
calzoneman 2013-08-13 11:18:06 -04:00
parent 77a2d9b0e2
commit f910f437bb
4 changed files with 25 additions and 2 deletions

View File

@ -1155,10 +1155,15 @@ Channel.prototype.tryQueue = function(user, data) {
if(user.rank < Rank.Moderator if(user.rank < Rank.Moderator
&& this.leader != user && this.leader != user
&& user.noflood("queue", 1.5)) { && user.noflood("queue", 3)) {
return; return;
} }
if(user.rank < Rank.Moderator && this.playlist.count(data.id) > 10) {
user.socket.emit("queueFail", "That video is already on the " +
"playlist 10 times.");
}
data.queueby = user ? user.name : ""; data.queueby = user ? user.name : "";
data.temp = !this.hasPermission(user, "addnontemp"); data.temp = !this.hasPermission(user, "addnontemp");

View File

@ -450,6 +450,15 @@ Playlist.prototype.clear = function() {
clearInterval(this._leadInterval); clearInterval(this._leadInterval);
} }
Playlist.prototype.count = function (id) {
var count = 0;
this.items.forEach(function (i) {
if(i.media.id === id)
count++;
});
return count;
}
Playlist.prototype.lead = function(lead) { Playlist.prototype.lead = function(lead) {
this.leading = lead; this.leading = lead;
var pl = this; var pl = this;

View File

@ -161,4 +161,13 @@ ULList.prototype.toArray = function(pack) {
return arr; return arr;
} }
/* iterate across the playlist */
ULList.prototype.forEach = function (fn) {
var item = this.first;
while(item !== null) {
fn(item);
item = item.next;
}
};
exports.ULList = ULList; exports.ULList = ULList;

View File

@ -757,7 +757,7 @@ Callbacks = {
} }
makeAlert("Error", data, "alert-error") makeAlert("Error", data, "alert-error")
.addClass("span12") .addClass("span12")
.insertAfter($("#mediaurl").parent()); .insertBefore($("#extended_controls"));
}, },
setTemp: function(data) { setTemp: function(data) {