mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
REST-endpoints and readme
This commit is contained in:
@@ -10,12 +10,14 @@ function frontpage_lists(msg, socket) {
|
||||
});
|
||||
}
|
||||
|
||||
function update_frontpage(coll, id, title) {
|
||||
function update_frontpage(coll, id, title, callback) {
|
||||
db.collection("frontpage_lists").update({_id: coll}, {$set: {
|
||||
id: id,
|
||||
title: title,
|
||||
accessed: Functions.get_time()}
|
||||
},{upsert: true}, function(err, returnDocs){});
|
||||
},{upsert: true}, function(err, returnDocs){
|
||||
if(typeof(callback) == "function") callback();
|
||||
});
|
||||
}
|
||||
|
||||
module.exports.frontpage_lists = frontpage_lists;
|
||||
|
||||
@@ -74,6 +74,7 @@ function list(msg, guid, coll, offline, socket) {
|
||||
|
||||
function skip(list, guid, coll, offline, socket) {
|
||||
var socketid = socket.zoff_id;
|
||||
|
||||
if(list !== undefined && list !== null && list !== "")
|
||||
{
|
||||
|
||||
@@ -81,7 +82,11 @@ function skip(list, guid, coll, offline, socket) {
|
||||
socket.emit("update_required");
|
||||
return;
|
||||
}
|
||||
|
||||
if(typeof(list.pass) != "string" || typeof(list.id) != "string" ||
|
||||
typeof(list.channel) != "string" || typeof(list.userpass) != "string") {
|
||||
socket.emit("toast", "update_required");
|
||||
return;
|
||||
}
|
||||
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)))) {
|
||||
|
||||
@@ -401,6 +406,7 @@ function end(obj, coll, guid, offline, socket) {
|
||||
return;
|
||||
}
|
||||
id = obj.id;
|
||||
|
||||
if(id !== undefined && id !== null && id !== "") {
|
||||
|
||||
if(coll == "" || coll == undefined || coll == null) {
|
||||
@@ -408,6 +414,12 @@ function end(obj, coll, guid, offline, socket) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(typeof(obj.id) != "string" || typeof(obj.channel) != "string" ||
|
||||
typeof(obj.pass) != "string") {
|
||||
socket.emit("toast", "update_required");
|
||||
return;
|
||||
}
|
||||
|
||||
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)))) {
|
||||
|
||||
@@ -491,7 +503,7 @@ function sendColor(coll, socket, id) {
|
||||
});
|
||||
}
|
||||
|
||||
function getNextSong(coll) {
|
||||
function getNextSong(coll, callback) {
|
||||
db.collection(coll).aggregate([{
|
||||
$match:{
|
||||
views:{
|
||||
@@ -514,6 +526,7 @@ function getNextSong(coll) {
|
||||
if(doc.length == 1) {
|
||||
io.to(coll).emit("next_song", {videoId: doc[0].id, title: doc[0].title});
|
||||
}
|
||||
if(typeof(callback) == "function") callback();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,17 @@ function add_function(arr, coll, guid, offline, socket) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(typeof(arr.id) != "string" || typeof(arr.start) != "number" ||
|
||||
typeof(arr.end) != "number" || typeof(arr.title) != "string" ||
|
||||
typeof(arr.list) != "string" || typeof(arr.duration) != "number" ||
|
||||
typeof(arr.playlist) != "boolean" || typeof(arr.num) != "number" ||
|
||||
typeof(arr.total) != "number" || typeof(arr.pass) != "string" ||
|
||||
typeof(arr.adminpass) != "string") {
|
||||
socket.emit("toast", "update_required");
|
||||
return;
|
||||
}
|
||||
|
||||
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)))) {
|
||||
|
||||
@@ -179,6 +190,13 @@ function voteUndecided(msg, coll, guid, offline, socket) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(typeof(msg.channel) != "string" || typeof(msg.id) != "string" ||
|
||||
typeof(msg.type) != "string" || typeof(msg.adminpass) != "string" ||
|
||||
typeof(msg.pass) != "string") {
|
||||
socket.emit("toast", "update_required");
|
||||
return;
|
||||
}
|
||||
|
||||
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)))) {
|
||||
|
||||
@@ -218,6 +236,12 @@ function shuffle(msg, coll, guid, offline, socket) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(typeof(msg.adminpass) != "string" || typeof(msg.channel) != "string" ||
|
||||
typeof(msg.pass) != "string") {
|
||||
socket.emit("toast", "update_required");
|
||||
return;
|
||||
}
|
||||
|
||||
Functions.check_inlist(coll, guid, socket, offline);
|
||||
var hash;
|
||||
if(msg.adminpass === "") hash = msg.adminpass;
|
||||
@@ -290,6 +314,11 @@ 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);
|
||||
|
||||
if(typeof(msg.channel) != "string" || typeof(msg.adminpass) != "string" ||
|
||||
typeof(msg.pass) != "string") {
|
||||
socket.emit("toast", "update_required");
|
||||
return;
|
||||
}
|
||||
db.collection(coll + "_settings").find(function(err, conf) {
|
||||
if(conf.length == 1 && conf) {
|
||||
conf = conf[0];
|
||||
|
||||
@@ -21,7 +21,6 @@ function password(inp, coll, guid, offline, socket) {
|
||||
|
||||
uncrypted = pw;
|
||||
pw = Functions.decrypt_string(socket.zoff_id, pw);
|
||||
|
||||
Functions.check_inlist(coll, guid, socket, offline);
|
||||
|
||||
if(inp.oldpass)
|
||||
@@ -44,6 +43,7 @@ function password(inp, coll, guid, offline, socket) {
|
||||
});
|
||||
}else
|
||||
socket.emit("toast", "wrongpass");
|
||||
socket.emit("pw", false);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -94,6 +94,15 @@ function conf_function(params, coll, guid, offline, socket) {
|
||||
var skipping = params.skipping;
|
||||
var shuffling = params.shuffling;
|
||||
var userpass = Functions.decrypt_string(socket.zoff_id, params.userpass);
|
||||
if(typeof(userpass) != "string" || typeof(adminpass) != "string" ||
|
||||
typeof(voting) != "boolean" || typeof(addsongs) != "boolean" ||
|
||||
typeof(longsongs) != "boolean" || typeof(frontpage) != "boolean" ||
|
||||
typeof(allvideos) != "boolean" || typeof(removeplay) != "boolean" ||
|
||||
typeof(skipping) != "boolean" || typeof(shuffling) != "boolean" ||
|
||||
typeof(params.userpass_changed) != "boolean") {
|
||||
socket.emit("toast", "wrongpass");
|
||||
return;
|
||||
}
|
||||
|
||||
if((!params.userpass_changed && frontpage) || (params.userpass_changed && userpass == "")) {
|
||||
userpass = "";
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
function thumbnail(msg, coll, guid, offline, socket) {
|
||||
if(msg.thumbnail && msg.channel && msg.adminpass && msg.thumbnail.indexOf("i.imgur.com") > -1){
|
||||
if(typeof(msg.channel) != "string" || typeof(msg.thumbnail) != "string" ||
|
||||
typeof(msg.adminpass) != "string" || typeof(msg.pass) != "string") {
|
||||
socket.emit("toast", "update_required");
|
||||
return;
|
||||
}
|
||||
msg.thumbnail = msg.thumbnail.replace(/^https?\:\/\//i, "");
|
||||
if(msg.thumbnail.substring(0,2) != "//") msg.thumbnail = "//" + msg.thumbnail;
|
||||
var channel = msg.channel.toLowerCase();
|
||||
@@ -23,6 +28,11 @@ function thumbnail(msg, coll, guid, offline, socket) {
|
||||
|
||||
function description(msg, coll, guid, offline, socket) {
|
||||
if(msg.description && msg.channel && msg.adminpass && msg.description.length < 100){
|
||||
if(typeof(msg.channel) != "string" || typeof(msg.description) != "string" ||
|
||||
typeof(msg.adminpass) != "string" || typeof(msg.pass) != "string") {
|
||||
socket.emit("toast", "update_required");
|
||||
return;
|
||||
}
|
||||
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){
|
||||
|
||||
Reference in New Issue
Block a user