mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-12-08 20:48:48 +00:00
Adding thumbnail/description and rules in api requests
This commit is contained in:
@@ -98,7 +98,7 @@ function list(msg, guid, coll, offline, socket) {
|
|||||||
} else {
|
} else {
|
||||||
db.createCollection(coll, function(err, docs){
|
db.createCollection(coll, function(err, docs){
|
||||||
db.collection(coll).createIndex({ id: 1}, {unique: true}, function(e, d) {
|
db.collection(coll).createIndex({ id: 1}, {unique: true}, function(e, d) {
|
||||||
var configs = {"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: "", id: "config"};
|
var configs = {"addsongs":false, "adminpass":"", "allvideos":true, "frontpage":true, "longsongs":false, "removeplay": false, "shuffle": true, "skip": false, "skips": [], "startTime":Functions.get_time(), "views": [], "vote": false, "description": "", "thumbnail": "", "rules": "", userpass: "", id: "config"};
|
||||||
db.collection(coll + "_settings").insert(configs, function(err, docs){
|
db.collection(coll + "_settings").insert(configs, function(err, docs){
|
||||||
socket.join(coll);
|
socket.join(coll);
|
||||||
send_list(coll, socket, true, false, true);
|
send_list(coll, socket, true, false, true);
|
||||||
|
|||||||
@@ -30,6 +30,26 @@ var toShowChannel = {
|
|||||||
source: 1,
|
source: 1,
|
||||||
thumbnail: 1,
|
thumbnail: 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var project_object = {
|
||||||
|
"_id": 0,
|
||||||
|
"id": 1,
|
||||||
|
"added": 1,
|
||||||
|
"now_playing": 1,
|
||||||
|
"title": 1,
|
||||||
|
"votes": 1,
|
||||||
|
"start": 1,
|
||||||
|
"duration": 1,
|
||||||
|
"end": 1,
|
||||||
|
"type": 1,
|
||||||
|
"source": { $ifNull: [ "$source", "youtube" ] },
|
||||||
|
"thumbnail": {
|
||||||
|
$ifNull: [ "$thumbnail", {
|
||||||
|
$concat : [ "https://img.youtube.com/vi/", "$id", "/mqdefault.jpg"]
|
||||||
|
} ]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
var toShowConfig = {
|
var toShowConfig = {
|
||||||
addsongs: 1,
|
addsongs: 1,
|
||||||
adminpass: 1,
|
adminpass: 1,
|
||||||
@@ -42,6 +62,10 @@ var toShowConfig = {
|
|||||||
startTime: 1,
|
startTime: 1,
|
||||||
userpass: 1,
|
userpass: 1,
|
||||||
vote: 1,
|
vote: 1,
|
||||||
|
toggleChat: 1,
|
||||||
|
description: { $ifNull: [ "$description", "" ] },
|
||||||
|
thumbnail: { $ifNull: [ "$thumbnail", "" ] },
|
||||||
|
rules: { $ifNull: [ "$rules", "" ] },
|
||||||
_id: 0
|
_id: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -915,8 +939,17 @@ router.route('/api/conf/:channel_name').get(function(req, res) {
|
|||||||
res.header({"Content-Type": "application/json"});
|
res.header({"Content-Type": "application/json"});
|
||||||
|
|
||||||
var channel_name = cleanChannelName(req.params.channel_name);
|
var channel_name = cleanChannelName(req.params.channel_name);
|
||||||
db.collection(channel_name + "_settings").find({ id: "config" }, toShowConfig, function(err, docs) {
|
db.collection(channel_name + "_settings").aggregate([
|
||||||
if(docs.length > 0 && docs[0].userpass == "" || docs[0].userpass == undefined) {
|
{
|
||||||
|
"$match": {
|
||||||
|
id: "config"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$project": toShowConfig
|
||||||
|
},
|
||||||
|
], function(err, docs) {
|
||||||
|
if(docs.length > 0 && (docs[0].userpass == "" || docs[0].userpass == undefined)) {
|
||||||
var conf = docs[0];
|
var conf = docs[0];
|
||||||
if(conf.adminpass != "") {
|
if(conf.adminpass != "") {
|
||||||
conf.adminpass = true;
|
conf.adminpass = true;
|
||||||
@@ -998,7 +1031,16 @@ router.route('/api/conf/:channel_name').post(function(req, res) {
|
|||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
db.collection(channel_name + "_settings").find({ id: "config" }, toShowConfig, function(err, docs) {
|
db.collection(channel_name + "_settings").aggregate([
|
||||||
|
{
|
||||||
|
"$match": {
|
||||||
|
id: "config"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"$project": toShowConfig
|
||||||
|
},
|
||||||
|
], function(err, docs) {
|
||||||
if(docs.length > 0 && docs[0].userpass == userpass) {
|
if(docs.length > 0 && docs[0].userpass == userpass) {
|
||||||
var conf = docs[0];
|
var conf = docs[0];
|
||||||
if(conf.adminpass != "") {
|
if(conf.adminpass != "") {
|
||||||
|
|||||||
Reference in New Issue
Block a user