Fixed issue where name of person skipping not being correctly sent

This commit is contained in:
Kasper Rynning-Tønnesen
2017-10-18 17:03:24 +02:00
parent 1dbf9931ea
commit 3b8e4ce952

View File

@@ -112,7 +112,17 @@ function skip(list, guid, coll, offline, socket) {
{
List.change_song(coll, error, video_id);
socket.emit("toast", "skip");
io.to(coll).emit('chat', {from: name, msg: " skipped"});
db.collection("user_names").find({"guid": guid}, function(err, docs) {
if(docs.length == 1) {
db.collection("registered_users").find({"_id": docs[0].name}, function(err, n) {
var icon = false;
if(n.length > 0 && n[0].icon) {
icon = n[0].icon;
}
io.to(coll).emit('chat', {from: docs[0].name, icon: icon, msg: " skipped"});
});
}
});
}else if(!Functions.contains(docs[0].skips, guid)){
db.collection(coll).update({views:{$exists:true}}, {$push:{skips:guid}}, function(err, d){
if(frontpage_viewers[0].viewers == 2)