mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Fix for list without conf
This commit is contained in:
@@ -142,7 +142,7 @@ function skip(list, guid, coll, offline, socket) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}else if(!Functions.contains(docs[0].skips, guid)){
|
}else if(!Functions.contains(docs[0].skips, guid)){
|
||||||
db.collection(coll + "_settings").update({views:{$exists:true}}, {$push:{skips:guid}}, function(err, d){
|
db.collection(coll + "_settings").update({ id: "config" }, {$push:{skips:guid}}, function(err, d){
|
||||||
if(frontpage_viewers[0].viewers == 2)
|
if(frontpage_viewers[0].viewers == 2)
|
||||||
to_skip = 1;
|
to_skip = 1;
|
||||||
else
|
else
|
||||||
@@ -206,7 +206,7 @@ function change_song(coll, error, id, callback) {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if((docs[0].skipped_time != undefined && docs[0].skipped_time != Functions.get_time()) || docs[0].skipped_time == undefined) {
|
if((docs[0].skipped_time != undefined && docs[0].skipped_time != Functions.get_time()) || docs[0].skipped_time == undefined) {
|
||||||
db.collection(coll + "_settings").update({views: {$exists: true}}, {$set: {skipped_time: Functions.get_time()}}, function(err, updated){
|
db.collection(coll + "_settings").update({id: "config"}, {$set: {skipped_time: Functions.get_time()}}, function(err, updated){
|
||||||
db.collection(coll).update({now_playing:true, id:id}, {
|
db.collection(coll).update({now_playing:true, id:id}, {
|
||||||
$set:{
|
$set:{
|
||||||
now_playing:false,
|
now_playing:false,
|
||||||
@@ -291,7 +291,7 @@ function change_song_post(coll, next_song, callback)
|
|||||||
added:Functions.get_time()
|
added:Functions.get_time()
|
||||||
}
|
}
|
||||||
}, function(err, returnDocs){
|
}, function(err, returnDocs){
|
||||||
db.collection(coll + "_settings").update({views: {$exists: true}}, {
|
db.collection(coll + "_settings").update({id: "configs"}, {
|
||||||
$set:{
|
$set:{
|
||||||
startTime:Functions.get_time(),
|
startTime:Functions.get_time(),
|
||||||
skips:[]
|
skips:[]
|
||||||
@@ -348,7 +348,7 @@ function send_list(coll, socket, send, list_send, configs, shuffled)
|
|||||||
added:Functions.get_time()
|
added:Functions.get_time()
|
||||||
}
|
}
|
||||||
}, function(err, returnDocs){
|
}, function(err, returnDocs){
|
||||||
db.collection(coll + "_settings").update({views:{$exists:true}}, {
|
db.collection(coll + "_settings").update({ id: "config" }, {
|
||||||
$set:{
|
$set:{
|
||||||
startTime: Functions.get_time(),
|
startTime: Functions.get_time(),
|
||||||
skips:[]
|
skips:[]
|
||||||
@@ -391,17 +391,21 @@ function send_list(coll, socket, send, list_send, configs, shuffled)
|
|||||||
List.send_play(coll, socket);
|
List.send_play(coll, socket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
if(configs)
|
||||||
|
{
|
||||||
if(configs)
|
if(conf.length > 0) {
|
||||||
{
|
if(conf[0].adminpass !== "") conf[0].adminpass = true;
|
||||||
if(conf.length > 0) {
|
if(conf[0].hasOwnProperty("userpass") && conf[0].userpass != "") conf[0].userpass = true;
|
||||||
if(conf[0].adminpass !== "") conf[0].adminpass = true;
|
else conf[0].userpass = false;
|
||||||
if(conf[0].hasOwnProperty("userpass") && conf[0].userpass != "") conf[0].userpass = true;
|
io.to(coll).emit("conf", conf);
|
||||||
else conf[0].userpass = false;
|
} else if(conf.length == 0 && docs.length > 0) {
|
||||||
io.to(coll).emit("conf", conf);
|
var conf = {"id": "config", "addsongs":false, "adminpass":"", "allvideos":true, "frontpage":true, "longsongs":false, "removeplay": false, "shuffle": true, "skip": false, "skips": [], "startTime":Functions.get_time(), "views": [], "vote": false, "desc": "", userpass: ""};
|
||||||
|
db.collection(coll + "_settings").update({id: "config"}, conf, {upsert: true}, function(err, docs) {
|
||||||
|
io.to(coll).emit("conf", conf);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
});
|
||||||
if(socket){
|
if(socket){
|
||||||
db.collection(coll).find({type:"suggested"}).sort({added: 1}, function(err, sugg){
|
db.collection(coll).find({type:"suggested"}).sort({added: 1}, function(err, sugg){
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ function add_function(arr, coll, guid, offline, socket) {
|
|||||||
new_song._id = "asd";
|
new_song._id = "asd";
|
||||||
if(np) {
|
if(np) {
|
||||||
List.send_list(coll, undefined, false, true, false);
|
List.send_list(coll, undefined, false, true, false);
|
||||||
db.collection(coll + "_settings").update({views:{$exists:true}}, {$set:{startTime: Functions.get_time()}});
|
db.collection(coll + "_settings").update({ id: "config" }, {$set:{startTime: Functions.get_time()}});
|
||||||
List.send_play(coll, undefined);
|
List.send_play(coll, undefined);
|
||||||
Frontpage.update_frontpage(coll, id, title);
|
Frontpage.update_frontpage(coll, id, title);
|
||||||
if(!full_list) Search.get_correct_info(new_song, coll, false);
|
if(!full_list) Search.get_correct_info(new_song, coll, false);
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ function password(inp, coll, guid, offline, socket) {
|
|||||||
{
|
{
|
||||||
if(docs[0].adminpass === "" || docs[0].adminpass == Functions.hash_pass(opw))
|
if(docs[0].adminpass === "" || docs[0].adminpass == Functions.hash_pass(opw))
|
||||||
{
|
{
|
||||||
db.collection(coll + "_settings").update({views:{$exists:true}}, {$set:{adminpass:Functions.hash_pass(pw)}}, function(err, docs){
|
db.collection(coll + "_settings").update({ id: "config" }, {$set:{adminpass:Functions.hash_pass(pw)}}, function(err, docs){
|
||||||
if(inp.oldpass)
|
if(inp.oldpass)
|
||||||
socket.emit("toast", "changedpass");
|
socket.emit("toast", "changedpass");
|
||||||
else
|
else
|
||||||
@@ -136,7 +136,7 @@ function conf_function(params, coll, guid, offline, socket) {
|
|||||||
} else if (frontpage) {
|
} else if (frontpage) {
|
||||||
obj["userpass"] = "";
|
obj["userpass"] = "";
|
||||||
}
|
}
|
||||||
db.collection(coll + "_settings").update({views:{$exists:true}}, {
|
db.collection(coll + "_settings").update({ id: "config" }, {
|
||||||
$set:obj
|
$set:obj
|
||||||
}, function(err, docs){
|
}, function(err, docs){
|
||||||
db.collection(coll + "_settings").find(function(err, docs){
|
db.collection(coll + "_settings").find(function(err, docs){
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ function thumbnail(msg, coll, guid, offline, socket) {
|
|||||||
if(msg.thumbnail.substring(0,2) != "//") msg.thumbnail = "//" + msg.thumbnail;
|
if(msg.thumbnail.substring(0,2) != "//") msg.thumbnail = "//" + msg.thumbnail;
|
||||||
var channel = msg.channel.toLowerCase();
|
var channel = msg.channel.toLowerCase();
|
||||||
var hash = Functions.hash_pass(Functions.decrypt_string(socket.zoff_id, msg.adminpass));
|
var hash = Functions.hash_pass(Functions.decrypt_string(socket.zoff_id, msg.adminpass));
|
||||||
db.collection(channel + "_settings").update({views: {$exists: true}}, function(err, docs){
|
db.collection(channel + "_settings").update({id: "configs"}, function(err, docs){
|
||||||
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socketid, msg.pass)))) {
|
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socketid, msg.pass)))) {
|
||||||
if(docs !== null && docs.length !== 0 && docs[0].adminpass !== "" && docs[0].adminpass == hash){
|
if(docs !== null && docs.length !== 0 && docs[0].adminpass !== "" && docs[0].adminpass == hash){
|
||||||
db.collection("suggested_thumbnails").update({channel: channel}, {$set:{thumbnail: msg.thumbnail}}, {upsert:true}, function(err, docs){
|
db.collection("suggested_thumbnails").update({channel: channel}, {$set:{thumbnail: msg.thumbnail}}, {upsert:true}, function(err, docs){
|
||||||
@@ -35,7 +35,7 @@ function description(msg, coll, guid, offline, socket) {
|
|||||||
}
|
}
|
||||||
var channel = msg.channel.toLowerCase();
|
var channel = msg.channel.toLowerCase();
|
||||||
var hash = Functions.hash_pass(Functions.decrypt_string(socket.zoff_id, msg.adminpass));
|
var hash = Functions.hash_pass(Functions.decrypt_string(socket.zoff_id, msg.adminpass));
|
||||||
db.collection(channel + "_settings").update({views: {$exists: true}}, function(err, docs){
|
db.collection(channel + "_settings").update({id: "configs"}, function(err, docs){
|
||||||
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socketid, msg.pass)))) {
|
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socketid, msg.pass)))) {
|
||||||
if(docs !== null && docs.length !== 0 && docs[0].adminpass !== "" && docs[0].adminpass == hash){
|
if(docs !== null && docs.length !== 0 && docs[0].adminpass !== "" && docs[0].adminpass == hash){
|
||||||
db.collection("suggested_descriptions").update({channel: channel}, {$set:{description: msg.description}}, {upsert:true}, function(err, docs){
|
db.collection("suggested_descriptions").update({channel: channel}, {$set:{description: msg.description}}, {upsert:true}, function(err, docs){
|
||||||
|
|||||||
Reference in New Issue
Block a user