Show links that failed for queueFail

This commit is contained in:
calzoneman 2013-10-06 01:43:25 -05:00
parent ce197d3d8a
commit 7d862cac60
4 changed files with 113 additions and 21 deletions

View File

@ -1,3 +1,9 @@
Sun Oct 06 01:42 2013 CDT
* lib/channel.js, www/assets/js/callbacks.js: Include the link that
failed with the queueFail packet. Clicking the "+ n more" tag
shows all links that failed for stacked messages
* lib/utilities.js: Add a formatLink function
Sat Oct 05 20:41 2013 CDT Sat Oct 05 20:41 2013 CDT
* lib/user.js: Fix a bug where duplicate guestnames were allowed with * lib/user.js: Fix a bug where duplicate guestnames were allowed with
different capitalizations different capitalizations

View File

@ -1332,7 +1332,10 @@ Channel.prototype.tryQueue = function(user, data) {
} }
if (user.queueLimiter.throttle(limit)) { if (user.queueLimiter.throttle(limit)) {
user.socket.emit("queueFail", "You are adding videos too quickly"); user.socket.emit("queueFail", {
msg: "You are adding videos too quickly",
link: null
});
return; return;
} }
@ -1370,20 +1373,29 @@ Channel.prototype.addMedia = function(data, user) {
var self = this; var self = this;
if(data.type === "yp" && if(data.type === "yp" &&
!self.hasPermission(user, "playlistaddlist")) { !self.hasPermission(user, "playlistaddlist")) {
user.socket.emit("queueFail", "You don't have permission to add " + user.socket.emit("queueFail", {
"playlists"); msg: "You don't have permission to add " +
"playlists",
link: $util.formatLink(data.id, data.type)
});
return; return;
} }
if(data.type === "cu" && if(data.type === "cu" &&
!self.hasPermission(user, "playlistaddcustom")) { !self.hasPermission(user, "playlistaddcustom")) {
user.socket.emit("queueFail", "You don't have permission to add " + user.socket.emit("queueFail", {
"custom embeds"); msg: "You don't have permission to add " +
"custom embeds",
link: null
});
return; return;
} }
if(isLive(data.type) && if(isLive(data.type) &&
!self.hasPermission(user, "playlistaddlive")) { !self.hasPermission(user, "playlistaddlive")) {
user.socket.emit("queueFail", "You don't have " + user.socket.emit("queueFail", {
"permission to add livestreams"); msg: "You don't have " +
"permission to add livestreams",
link: $util.formatLink(data.id, data.type)
});
return; return;
} }
data.temp = data.temp || isLive(data.type); data.temp = data.temp || isLive(data.type);
@ -1403,8 +1415,10 @@ Channel.prototype.addMedia = function(data, user) {
var afterData = function (q, c, m) { var afterData = function (q, c, m) {
if (data.maxlength && m.seconds > data.maxlength) { if (data.maxlength && m.seconds > data.maxlength) {
user.socket.emit("queueFail", user.socket.emit("queueFail", {
"Media is too long!"); msg: "Media is too long!",
link: $util.formatLink(m.id, m.type)
});
q.release(); q.release();
return; return;
} }
@ -1414,7 +1428,10 @@ Channel.prototype.addMedia = function(data, user) {
m.temp = data.temp; m.temp = data.temp;
var res = self.playlist.addMedia(m); var res = self.playlist.addMedia(m);
if (res.error) { if (res.error) {
user.socket.emit("queueFail", res.error); user.socket.emit("queueFail", {
msg: res.error,
link: $util.formatLink(m.id, m.type)
});
q.release(); q.release();
return; return;
} }
@ -1449,7 +1466,10 @@ Channel.prototype.addMedia = function(data, user) {
self.server.infogetter.getMedia(data.id, data.type, self.server.infogetter.getMedia(data.id, data.type,
function (e, vids) { function (e, vids) {
if (e) { if (e) {
user.socket.emit("queueFail", e); user.socket.emit("queueFail", {
msg: e,
link: $util.formatLink(data.id, data.type)
});
q.release(); q.release();
return; return;
} }
@ -1483,7 +1503,10 @@ Channel.prototype.addMedia = function(data, user) {
if (self.dead) if (self.dead)
return; return;
if (e) { if (e) {
user.socket.emit("queueFail", e); user.socket.emit("queueFail", {
msg: e,
link: $util.formatLink(data.id, data.type)
});
q.release(); q.release();
return; return;
} }
@ -1498,13 +1521,19 @@ Channel.prototype.addMedia = function(data, user) {
return; return;
if (err) { if (err) {
user.socket.emit("queueFail", "Internal error: " + err); user.socket.emit("queueFail", {
msg: "Internal error: " + err,
link: $util.formatLink(data.id, data.type)
});
return; return;
} }
if (item !== null) { if (item !== null) {
if (data.maxlength && item.seconds > data.maxlength) { if (data.maxlength && item.seconds > data.maxlength) {
user.socket.emit("queueFail", "Media is too long!"); user.socket.emit("queueFail", {
msg: "Media is too long!",
link: $util.formatLink(item.id, item.type)
});
return; return;
} }
@ -1522,7 +1551,10 @@ Channel.prototype.addMedia = function(data, user) {
if (self.dead) if (self.dead)
return; return;
if (e) { if (e) {
user.socket.emit("queueFail", e); user.socket.emit("queueFail", {
msg: e,
link: $util.formatLink(data.id, data.type)
});
q.release(); q.release();
return; return;
} }

View File

@ -98,5 +98,34 @@ module.exports = {
return false; return false;
} }
}; };
},
formatLink: function (id, type) {
switch (type) {
case "yt":
return "http://youtu.be/" + id;
case "vi":
return "http://vimeo.com/" + id;
case "dm":
return "http://dailymotion.com/video/" + id;
case "sc":
return id;
case "li":
return "http://livestream.com/" + id;
case "tw":
return "http://twitch.tv/" + id;
case "jt":
return "http://justin.tv/" + id;
case "rt":
return id;
case "jw":
return id;
case "im":
return "http://imgur.com/a/" + id;
case "us":
return "http://ustream.tv/" + id;
default:
return "";
}
} }
}; };

View File

@ -802,8 +802,10 @@ Callbacks = {
}); });
}, },
queueFail: function(data) { queueFail: function (data) {
if (!data || data === true) { if (!data)
data = { link: null };
if (!data.msg || data.msg === true) {
data = "Queue failed. Check your link to make sure it is valid."; data = "Queue failed. Check your link to make sure it is valid.";
} }
var alerts = $(".qfalert"); var alerts = $(".qfalert");
@ -811,21 +813,44 @@ Callbacks = {
var al = $(alerts[i]); var al = $(alerts[i]);
var cl = al.clone(); var cl = al.clone();
cl.children().remove(); cl.children().remove();
if (cl.text() === data) { if (cl.text() === data.msg) {
var tag = al.find(".label-important"); var tag = al.find(".label-important");
if (tag.length > 0) { if (tag.length > 0) {
var morelinks = al.find(".qflinks");
$("<a/>").attr("href", data.link)
.attr("target", "_blank")
.text(data.link)
.appendTo(morelinks);
$("<br/>").appendTo(morelinks);
var count = parseInt(tag.text().match(/\d+/)[0]) + 1; var count = parseInt(tag.text().match(/\d+/)[0]) + 1;
tag.text(tag.text().replace(/\d+/, ""+count)); tag.text(tag.text().replace(/\d+/, ""+count));
} else { } else {
$("<span/>") var tag = $("<span/>")
.addClass("label label-important pull-right") .addClass("label label-important pull-right pointer")
.text("+ 1 more") .text("+ 1 more")
.appendTo(al); .appendTo(al);
var morelinks = $("<div/>")
.addClass("qflinks")
.appendTo(al)
.hide();
$("<a/>").attr("href", data.link)
.attr("target", "_blank")
.text(data.link)
.appendTo(morelinks);
$("<br/>").appendTo(morelinks);
tag.click(function () {
morelinks.toggle();
});
} }
return; return;
} }
} }
makeAlert("Error", data, "alert-error") var text = data.msg;
if (typeof data.link === "string") {
text += "<br><a href='" + data.link + "' target='_blank'>" +
data.link + "</a>";
}
makeAlert("Error", text, "alert-error")
.addClass("span12 qfalert") .addClass("span12 qfalert")
.insertBefore($("#extended_controls")); .insertBefore($("#extended_controls"));
}, },