mirror of https://github.com/calzoneman/sync.git
Add a few limits
This commit is contained in:
parent
0491ea11da
commit
c8ce8b530a
14
channel.js
14
channel.js
|
@ -1231,23 +1231,13 @@ Channel.prototype.tryQueue = function(user, data) {
|
||||||
&& this.leader != user
|
&& this.leader != user
|
||||||
&& user.noflood("queue", 3)) {
|
&& user.noflood("queue", 3)) {
|
||||||
return;
|
return;
|
||||||
|
} else if (user.rank < Rank.Siteadmin && user.noflood("queue", 0.5)) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(typeof data.title !== "string")
|
if(typeof data.title !== "string")
|
||||||
data.title = false;
|
data.title = false;
|
||||||
|
|
||||||
var count = this.playlist.count(data.id);
|
|
||||||
|
|
||||||
if(user.rank < Rank.Moderator && count >= 5) {
|
|
||||||
user.socket.emit("queueFail", "That video is already on the " +
|
|
||||||
"playlist 5 times.");
|
|
||||||
return;
|
|
||||||
} else if(user.rank < Rank.Siteadmin && count >= 20) {
|
|
||||||
user.socket.emit("queueFail", "That video is already on the " +
|
|
||||||
"playlist 20 times.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
data.queueby = user ? user.name : "";
|
data.queueby = user ? user.name : "";
|
||||||
data.temp = !this.hasPermission(user, "addnontemp");
|
data.temp = !this.hasPermission(user, "addnontemp");
|
||||||
|
|
||||||
|
|
40
playlist.js
40
playlist.js
|
@ -169,20 +169,29 @@ Playlist.prototype.makeItem = function(media) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Playlist.prototype.add = function(item, pos) {
|
Playlist.prototype.add = function(item, pos) {
|
||||||
var success;
|
if(this.items.length >= 4000)
|
||||||
if(pos == "append")
|
return "Playlist limit reached (4,000)";
|
||||||
success = this.items.append(item);
|
|
||||||
else if(pos == "prepend")
|
|
||||||
success = this.items.prepend(item);
|
|
||||||
else
|
|
||||||
success = this.items.insertAfter(item, pos);
|
|
||||||
|
|
||||||
if(success && this.items.length == 1) {
|
if(this.items.findVideoId(item.media.id))
|
||||||
|
return "This item is already on the playlist";
|
||||||
|
|
||||||
|
if(pos == "append") {
|
||||||
|
if(!this.items.append(item))
|
||||||
|
return "Playlist failure";
|
||||||
|
} else if(pos == "prepend") {
|
||||||
|
if(!this.items.prepend(item))
|
||||||
|
return "Playlist failure";
|
||||||
|
} else {
|
||||||
|
if(!this.items.insertAfter(item, pos))
|
||||||
|
return "Playlist failure";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.items.length == 1) {
|
||||||
this.current = item;
|
this.current = item;
|
||||||
this.startPlayback();
|
this.startPlayback();
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Playlist.prototype.addCachedMedia = function(data, callback) {
|
Playlist.prototype.addCachedMedia = function(data, callback) {
|
||||||
|
@ -202,8 +211,8 @@ Playlist.prototype.addCachedMedia = function(data, callback) {
|
||||||
|
|
||||||
var action = {
|
var action = {
|
||||||
fn: function() {
|
fn: function() {
|
||||||
if(pl.add(it, pos))
|
var err = pl.add(it, pos);
|
||||||
callback(false, it);
|
callback(err, err ? null : it);
|
||||||
},
|
},
|
||||||
waiting: false
|
waiting: false
|
||||||
};
|
};
|
||||||
|
@ -229,9 +238,8 @@ Playlist.prototype.addMedia = function(data, callback) {
|
||||||
var pl = this;
|
var pl = this;
|
||||||
var action = {
|
var action = {
|
||||||
fn: function() {
|
fn: function() {
|
||||||
if(pl.add(it, pos)) {
|
var err = pl.add(it, pos);
|
||||||
callback(false, it);
|
callback(err, err ? null : it);
|
||||||
}
|
|
||||||
},
|
},
|
||||||
waiting: true
|
waiting: true
|
||||||
};
|
};
|
||||||
|
@ -331,8 +339,8 @@ Playlist.prototype.addYouTubePlaylist = function(data, callback) {
|
||||||
it.queueby = data.queueby;
|
it.queueby = data.queueby;
|
||||||
pl.queueAction({
|
pl.queueAction({
|
||||||
fn: function() {
|
fn: function() {
|
||||||
if(pl.add(it, pos))
|
var err = pl.add(it, pos);
|
||||||
callback(false, it);
|
callback(err, err ? null : it);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
11
ullist.js
11
ullist.js
|
@ -170,4 +170,15 @@ ULList.prototype.forEach = function (fn) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* find a media with the given video id */
|
||||||
|
ULList.prototype.findVideoId = function (id) {
|
||||||
|
var item = this.first;
|
||||||
|
while(item !== null) {
|
||||||
|
if(item.media && item.media.id === id)
|
||||||
|
return true;
|
||||||
|
item = item.next;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
exports.ULList = ULList;
|
exports.ULList = ULList;
|
||||||
|
|
Loading…
Reference in New Issue