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)){
|
||||
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)
|
||||
to_skip = 1;
|
||||
else
|
||||
@@ -206,7 +206,7 @@ function change_song(coll, error, id, callback) {
|
||||
});
|
||||
} else {
|
||||
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}, {
|
||||
$set:{
|
||||
now_playing:false,
|
||||
@@ -291,7 +291,7 @@ function change_song_post(coll, next_song, callback)
|
||||
added:Functions.get_time()
|
||||
}
|
||||
}, function(err, returnDocs){
|
||||
db.collection(coll + "_settings").update({views: {$exists: true}}, {
|
||||
db.collection(coll + "_settings").update({id: "configs"}, {
|
||||
$set:{
|
||||
startTime:Functions.get_time(),
|
||||
skips:[]
|
||||
@@ -348,7 +348,7 @@ function send_list(coll, socket, send, list_send, configs, shuffled)
|
||||
added:Functions.get_time()
|
||||
}
|
||||
}, function(err, returnDocs){
|
||||
db.collection(coll + "_settings").update({views:{$exists:true}}, {
|
||||
db.collection(coll + "_settings").update({ id: "config" }, {
|
||||
$set:{
|
||||
startTime: Functions.get_time(),
|
||||
skips:[]
|
||||
@@ -391,17 +391,21 @@ function send_list(coll, socket, send, list_send, configs, shuffled)
|
||||
List.send_play(coll, socket);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if(configs)
|
||||
{
|
||||
if(conf.length > 0) {
|
||||
if(conf[0].adminpass !== "") conf[0].adminpass = true;
|
||||
if(conf[0].hasOwnProperty("userpass") && conf[0].userpass != "") conf[0].userpass = true;
|
||||
else conf[0].userpass = false;
|
||||
io.to(coll).emit("conf", conf);
|
||||
if(configs)
|
||||
{
|
||||
if(conf.length > 0) {
|
||||
if(conf[0].adminpass !== "") conf[0].adminpass = true;
|
||||
if(conf[0].hasOwnProperty("userpass") && conf[0].userpass != "") conf[0].userpass = true;
|
||||
else conf[0].userpass = false;
|
||||
io.to(coll).emit("conf", conf);
|
||||
} else if(conf.length == 0 && docs.length > 0) {
|
||||
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){
|
||||
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";
|
||||
if(np) {
|
||||
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);
|
||||
Frontpage.update_frontpage(coll, id, title);
|
||||
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))
|
||||
{
|
||||
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)
|
||||
socket.emit("toast", "changedpass");
|
||||
else
|
||||
@@ -136,7 +136,7 @@ function conf_function(params, coll, guid, offline, socket) {
|
||||
} else if (frontpage) {
|
||||
obj["userpass"] = "";
|
||||
}
|
||||
db.collection(coll + "_settings").update({views:{$exists:true}}, {
|
||||
db.collection(coll + "_settings").update({ id: "config" }, {
|
||||
$set:obj
|
||||
}, 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;
|
||||
var channel = msg.channel.toLowerCase();
|
||||
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 !== 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){
|
||||
@@ -35,7 +35,7 @@ function description(msg, coll, guid, offline, socket) {
|
||||
}
|
||||
var channel = msg.channel.toLowerCase();
|
||||
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 !== 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){
|
||||
|
||||
Reference in New Issue
Block a user