mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Updating to use different collection for channelsettings
This commit is contained in:
@@ -30,7 +30,7 @@ function chat(msg, guid, offline, socket) {
|
||||
return;
|
||||
}
|
||||
var coll = msg.channel;
|
||||
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
||||
db.collection(coll + "_settings").find(function(err, docs){
|
||||
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socket.zoff_id, msg.pass)))) {
|
||||
var data = msg.data;
|
||||
Functions.check_inlist(coll, guid, socket, offline);
|
||||
|
||||
@@ -383,7 +383,7 @@ module.exports = function() {
|
||||
return;
|
||||
}
|
||||
|
||||
db.collection(coll).find({views: {$exists: true}}, function(err, docs) {
|
||||
db.collection(coll + "_settings").find(function(err, docs) {
|
||||
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (obj.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socketid, obj.pass)))) {
|
||||
Functions.check_inlist(coll, guid, socket, offline);
|
||||
List.send_play(coll, socket);
|
||||
|
||||
@@ -34,7 +34,7 @@ function list(msg, guid, coll, offline, socket) {
|
||||
db.collection('frontpage_lists').find({"_id": coll}, function(err, frontpage_lists){
|
||||
if(frontpage_lists.length == 1)
|
||||
{
|
||||
db.collection(coll).find({views: {$exists: true}}, function(err, docs) {
|
||||
db.collection(coll + "_settings").find(function(err, docs) {
|
||||
if(docs.length == 0 || (docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || docs[0].userpass == pass))) {
|
||||
if(docs.length > 0 && docs[0].hasOwnProperty('userpass') && docs[0].userpass != "" && docs[0].userpass == pass) {
|
||||
socket.emit("auth_accepted", {value: true});
|
||||
@@ -82,7 +82,7 @@ function skip(list, guid, coll, offline, socket) {
|
||||
return;
|
||||
}
|
||||
|
||||
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
||||
db.collection(coll + "_settings").find(function(err, docs){
|
||||
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (list.hasOwnProperty('userpass') && docs[0].userpass == Functions.decrypt_string(socketid, list.userpass)))) {
|
||||
|
||||
Functions.check_inlist(coll, guid, socket, offline);
|
||||
@@ -104,7 +104,7 @@ function skip(list, guid, coll, offline, socket) {
|
||||
else
|
||||
hash = "";
|
||||
|
||||
db.collection(coll).find({views: {$exists:true}}, function(err, docs){
|
||||
db.collection(coll + "_settings").find(function(err, docs){
|
||||
|
||||
if(docs !== null && docs.length !== 0)
|
||||
{
|
||||
@@ -129,7 +129,7 @@ function skip(list, guid, coll, offline, socket) {
|
||||
}
|
||||
});
|
||||
}else if(!Functions.contains(docs[0].skips, guid)){
|
||||
db.collection(coll).update({views:{$exists:true}}, {$push:{skips:guid}}, function(err, d){
|
||||
db.collection(coll + "_settings").update({views:{$exists:true}}, {$push:{skips:guid}}, function(err, d){
|
||||
if(frontpage_viewers[0].viewers == 2)
|
||||
to_skip = 1;
|
||||
else
|
||||
@@ -155,7 +155,7 @@ function skip(list, guid, coll, offline, socket) {
|
||||
}
|
||||
|
||||
function change_song(coll, error, id, callback) {
|
||||
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
||||
db.collection(coll + "_settings").find(function(err, docs){
|
||||
var startTime = docs[0].startTime;
|
||||
if(docs !== null && docs.length !== 0)
|
||||
{
|
||||
@@ -193,7 +193,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).update({views: {$exists: true}}, {$set: {skipped_time: Functions.get_time()}}, function(err, updated){
|
||||
db.collection(coll + "_settings").update({views: {$exists: true}}, {$set: {skipped_time: Functions.get_time()}}, function(err, updated){
|
||||
db.collection(coll).update({now_playing:true, id:id}, {
|
||||
$set:{
|
||||
now_playing:false,
|
||||
@@ -278,13 +278,13 @@ function change_song_post(coll, next_song, callback)
|
||||
added:Functions.get_time()
|
||||
}
|
||||
}, function(err, returnDocs){
|
||||
db.collection(coll).update({views:{$exists:true}},{
|
||||
db.collection(coll + "_settings").update({views: {$exists: true}}, {
|
||||
$set:{
|
||||
startTime:Functions.get_time(),
|
||||
skips:[]
|
||||
}
|
||||
}, function(err, returnDocs){
|
||||
db.collection(coll).find({views:{$exists:true}}, function(err, conf){
|
||||
db.collection(coll + "_settings").find(function(err, conf){
|
||||
if(!callback) {
|
||||
io.to(coll).emit("channel", {type: "song_change", time: Functions.get_time(), remove: conf[0].removeplay});
|
||||
List.send_play(coll);
|
||||
@@ -301,7 +301,7 @@ function change_song_post(coll, next_song, callback)
|
||||
|
||||
function send_list(coll, socket, send, list_send, configs, shuffled)
|
||||
{
|
||||
db.collection(coll).find({views:{$exists:true}}, function(err, conf){
|
||||
db.collection(coll + "_settings").find(function(err, conf){
|
||||
db.collection(coll).find({views:{$exists:false}, type: {$ne: "suggested"}}, function(err, docs)
|
||||
{
|
||||
if(docs.length > 0) {
|
||||
@@ -335,7 +335,7 @@ function send_list(coll, socket, send, list_send, configs, shuffled)
|
||||
added:Functions.get_time()
|
||||
}
|
||||
}, function(err, returnDocs){
|
||||
db.collection(coll).update({views:{$exists:true}}, {
|
||||
db.collection(coll + "_settings").update({views:{$exists:true}}, {
|
||||
$set:{
|
||||
startTime: Functions.get_time(),
|
||||
skips:[]
|
||||
@@ -408,14 +408,14 @@ function end(obj, coll, guid, offline, socket) {
|
||||
return;
|
||||
}
|
||||
|
||||
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
||||
db.collection(coll + "_settings").find(function(err, docs){
|
||||
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (obj.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socketid, obj.pass)))) {
|
||||
|
||||
Functions.check_inlist(coll, guid, socket, offline);
|
||||
db.collection(coll).find({now_playing:true}, function(err, np){
|
||||
if(err !== null) console.log(err);
|
||||
if(np !== null && np !== undefined && np.length == 1 && np[0].id == id){
|
||||
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
||||
db.collection(coll + "_settings").find(function(err, docs){
|
||||
var startTime = docs[0].startTime;
|
||||
if(docs[0].removeplay === true && startTime+parseInt(np[0].duration)<=Functions.get_time()+5)
|
||||
{
|
||||
@@ -444,7 +444,7 @@ function end(obj, coll, guid, offline, socket) {
|
||||
function send_play(coll, socket)
|
||||
{
|
||||
db.collection(coll).find({now_playing:true}, function(err, np){
|
||||
db.collection(coll).find({views:{$exists:true}}, function(err, conf){
|
||||
db.collection(coll + "_settings").find(function(err, conf){
|
||||
if(err !== null) console.log(err);
|
||||
try{
|
||||
if(Functions.get_time()-conf[0].startTime > np[0].duration){
|
||||
|
||||
@@ -11,7 +11,7 @@ function add_function(arr, coll, guid, offline, socket) {
|
||||
var start = arr.start;
|
||||
var end = arr.end;
|
||||
|
||||
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
||||
db.collection(coll + "_settings").find(function(err, docs){
|
||||
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (arr.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socketid, arr.pass)))) {
|
||||
|
||||
Functions.check_inlist(coll, guid, socket, offline);
|
||||
@@ -24,7 +24,7 @@ function add_function(arr, coll, guid, offline, socket) {
|
||||
var last = arr.num == arr.total - 1;
|
||||
var num = arr.num;
|
||||
var total = arr.total;
|
||||
/*db.collection(coll).find({views:{$exists:true}}, function(err, docs)
|
||||
/*db.collection(coll + "_settings").find(function(err, docs)
|
||||
{*/
|
||||
conf = docs;
|
||||
if(docs !== null && docs.length !== 0 && ((docs[0].addsongs === true && (hash == docs[0].adminpass || docs[0].adminpass === "")) ||
|
||||
@@ -86,7 +86,7 @@ function add_function(arr, coll, guid, offline, socket) {
|
||||
{
|
||||
var new_song = {"added": added,"guids":guids,"id":id,"now_playing":np,"title":title,"votes":votes, "duration":duration, "start": parseInt(start), "end": parseInt(end)};
|
||||
List.send_list(coll, undefined, false, true, false);
|
||||
db.collection(coll).update({views:{$exists:true}}, {$set:{startTime: Functions.get_time()}});
|
||||
db.collection(coll + "_settings").update({views:{$exists:true}}, {$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);
|
||||
@@ -163,7 +163,7 @@ function voteUndecided(msg, coll, guid, offline, socket) {
|
||||
return;
|
||||
}
|
||||
|
||||
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
||||
db.collection(coll + "_settings").find(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)))) {
|
||||
|
||||
Functions.check_inlist(coll, guid, socket, offline);
|
||||
@@ -174,7 +174,7 @@ function voteUndecided(msg, coll, guid, offline, socket) {
|
||||
{
|
||||
var id = msg.id;
|
||||
var hash = Functions.hash_pass(Functions.decrypt_string(socketid, msg.adminpass));
|
||||
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
||||
db.collection(coll + "_settings").find(function(err, docs){
|
||||
if(docs !== null && docs.length !== 0 && ((docs[0].vote === true && (hash == docs[0].adminpass || docs[0].adminpass === "")) ||
|
||||
docs[0].vote === false))
|
||||
{
|
||||
@@ -206,7 +206,7 @@ function shuffle(msg, coll, guid, offline, socket) {
|
||||
var hash;
|
||||
if(msg.adminpass === "") hash = msg.adminpass;
|
||||
else hash = Functions.hash_pass(Functions.decrypt_string(socketid, msg.adminpass));
|
||||
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
||||
db.collection(coll + "_settings").find(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 == hash || docs[0].adminpass === "") || docs[0].shuffle === false))
|
||||
{
|
||||
@@ -246,7 +246,7 @@ function del(params, socket, socketid) {
|
||||
coll = coll.replace("_", "");
|
||||
coll = encodeURIComponent(coll).replace(/\W/g, '');
|
||||
coll = filter.clean(coll);
|
||||
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
||||
db.collection(coll + "_settings").find(function(err, docs){
|
||||
if(docs !== null && docs.length !== 0 && docs[0].adminpass == Functions.hash_pass(Functions.decrypt_string(socketid, params.adminpass)))
|
||||
{
|
||||
db.collection(coll).find({id:params.id}, function(err, docs){
|
||||
@@ -274,7 +274,7 @@ function delete_all(msg, coll, guid, offline, socket) {
|
||||
var hash = Functions.hash_pass(Functions.decrypt_string(socketid, msg.adminpass));
|
||||
var hash_userpass = Functions.decrypt_string(socketid, msg.pass);
|
||||
|
||||
db.collection(coll).find({views: {$exists: true}}, function(err, conf) {
|
||||
db.collection(coll + "_settings").find(function(err, conf) {
|
||||
if(conf.length == 1 && conf) {
|
||||
conf = conf[0];
|
||||
if(conf.adminpass == hash && conf.adminpass != "" && (conf.userpass == "" || conf.userpass == undefined || (conf.userpass != "" && conf.userpass != undefined && conf.pass == hash_userpass))) {
|
||||
|
||||
@@ -30,12 +30,12 @@ function password(inp, coll, guid, offline, socket) {
|
||||
}
|
||||
opw = Functions.decrypt_string(socket.zoff_id, opw);
|
||||
|
||||
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
||||
db.collection(coll + "_settings").find(function(err, docs){
|
||||
if(docs !== null && docs.length !== 0)
|
||||
{
|
||||
if(docs[0].adminpass === "" || docs[0].adminpass == Functions.hash_pass(opw))
|
||||
{
|
||||
db.collection(coll).update({views:{$exists:true}}, {$set:{adminpass:Functions.hash_pass(pw)}}, function(err, docs){
|
||||
db.collection(coll + "_settings").update({views:{$exists:true}}, {$set:{adminpass:Functions.hash_pass(pw)}}, function(err, docs){
|
||||
if(inp.oldpass)
|
||||
socket.emit("toast", "changedpass");
|
||||
else
|
||||
@@ -109,7 +109,7 @@ function conf_function(params, coll, guid, offline, socket) {
|
||||
} else {
|
||||
hash = adminpass;
|
||||
}
|
||||
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
||||
db.collection(coll + "_settings").find(function(err, docs){
|
||||
if(docs !== null && docs.length !== 0 && (docs[0].adminpass === "" || docs[0].adminpass == hash)) {
|
||||
var obj = {
|
||||
addsongs:addsongs,
|
||||
@@ -128,10 +128,10 @@ function conf_function(params, coll, guid, offline, socket) {
|
||||
} else if (frontpage) {
|
||||
obj["userpass"] = "";
|
||||
}
|
||||
db.collection(coll).update({views:{$exists:true}}, {
|
||||
db.collection(coll + "_settings").update({views:{$exists:true}}, {
|
||||
$set:obj
|
||||
}, function(err, docs){
|
||||
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
||||
db.collection(coll + "_settings").find(function(err, docs){
|
||||
if(docs[0].adminpass !== "") docs[0].adminpass = true;
|
||||
if(docs[0].hasOwnProperty("userpass") && docs[0].userpass != "") docs[0].userpass = true;
|
||||
else docs[0].userpass = false;
|
||||
|
||||
@@ -4,7 +4,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).find({views:{$exists:true}}, function(err, docs){
|
||||
db.collection(channel + "_settings").update({views: {$exists: true}}, 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){
|
||||
@@ -25,7 +25,7 @@ function description(msg, coll, guid, offline, socket) {
|
||||
if(msg.description && msg.channel && msg.adminpass && msg.description.length < 100){
|
||||
var channel = msg.channel.toLowerCase();
|
||||
var hash = Functions.hash_pass(Functions.decrypt_string(socket.zoff_id, msg.adminpass));
|
||||
db.collection(channel).find({views:{$exists:true}}, function(err, docs){
|
||||
db.collection(channel + "_settings").update({views: {$exists: true}}, 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