mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Updating lists when rules/description and thumbnail is updated
This commit is contained in:
@@ -8,6 +8,7 @@ var token_db = mongojs("tokens");
|
|||||||
var uniqid = require('uniqid');
|
var uniqid = require('uniqid');
|
||||||
var crypto = require('crypto');
|
var crypto = require('crypto');
|
||||||
var ObjectId = mongojs.ObjectId;
|
var ObjectId = mongojs.ObjectId;
|
||||||
|
var sIO = require(path.join(__dirname, '../../apps/client.js')).socketIO;
|
||||||
|
|
||||||
router.use(function(req, res, next) {
|
router.use(function(req, res, next) {
|
||||||
next(); // make sure we go to the next routes and don't stop here
|
next(); // make sure we go to the next routes and don't stop here
|
||||||
@@ -61,7 +62,13 @@ router.route('/api/approve_thumbnail').post(function(req, res){
|
|||||||
db.collection("frontpage_lists").update({_id: channel}, {$set:{thumbnail: thumbnail}}, {upsert: true}, function(err, docs){
|
db.collection("frontpage_lists").update({_id: channel}, {$set:{thumbnail: thumbnail}}, {upsert: true}, function(err, docs){
|
||||||
db.collection(channel + "_settings").update({views:{$exists:true}}, {$set:{thumbnail: thumbnail}}, {upsert: true}, function(err, docs){
|
db.collection(channel + "_settings").update({views:{$exists:true}}, {$set:{thumbnail: thumbnail}}, {upsert: true}, function(err, docs){
|
||||||
db.collection("suggested_thumbnails").remove({channel: channel}, function(err, docs){
|
db.collection("suggested_thumbnails").remove({channel: channel}, function(err, docs){
|
||||||
res.send(true);
|
db.collection(channel + "_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;
|
||||||
|
sIO.to(channel).emit("conf", docs);
|
||||||
|
res.send(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -90,7 +97,13 @@ router.route('/api/approve_rules').post(function(req, res){
|
|||||||
var rules = docs[0].rules;
|
var rules = docs[0].rules;
|
||||||
db.collection(channel + "_settings").update({views:{$exists:true}}, {$set:{rules: rules}}, {upsert: true}, function(err, docs){
|
db.collection(channel + "_settings").update({views:{$exists:true}}, {$set:{rules: rules}}, {upsert: true}, function(err, docs){
|
||||||
db.collection("suggested_rules").remove({channel: channel}, function(err, docs){
|
db.collection("suggested_rules").remove({channel: channel}, function(err, docs){
|
||||||
res.send(true);
|
db.collection(channel + "_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;
|
||||||
|
sIO.to(channel).emit("conf", docs);
|
||||||
|
res.send(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -113,8 +126,14 @@ router.route('/api/deny_rules').post(function(req, res){
|
|||||||
router.route('/api/remove_rules').post(function(req, res){
|
router.route('/api/remove_rules').post(function(req, res){
|
||||||
if(req.isAuthenticated()){
|
if(req.isAuthenticated()){
|
||||||
var channel = req.body.channel;
|
var channel = req.body.channel;
|
||||||
db.collection(channel + "_settings").update({views:{$exists:true}}, {$set:{rules: ""}}, function(err, docs){
|
db.collection(channel + "_settings").update({views:{$exists:true}}, {$set:{rules: ""}}, function(err, docs){
|
||||||
res.send(true);
|
db.collection(channel + "_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;
|
||||||
|
sIO.to(channel).emit("conf", docs);
|
||||||
|
res.send(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
res.send(false);
|
res.send(false);
|
||||||
@@ -129,7 +148,13 @@ router.route('/api/approve_description').post(function(req, res){
|
|||||||
db.collection("frontpage_lists").update({_id: channel}, {$set:{description: description}}, {upsert: true}, function(err, docs){
|
db.collection("frontpage_lists").update({_id: channel}, {$set:{description: description}}, {upsert: true}, function(err, docs){
|
||||||
db.collection(channel + "_settings").update({views:{$exists:true}}, {$set:{description: description}}, function(err, docs){
|
db.collection(channel + "_settings").update({views:{$exists:true}}, {$set:{description: description}}, function(err, docs){
|
||||||
db.collection("suggested_descriptions").remove({channel: channel}, function(err, docs){
|
db.collection("suggested_descriptions").remove({channel: channel}, function(err, docs){
|
||||||
res.send(true);
|
db.collection(channel + "_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;
|
||||||
|
sIO.to(channel).emit("conf", docs);
|
||||||
|
res.send(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -155,7 +180,13 @@ router.route('/api/remove_thumbnail').post(function(req, res){
|
|||||||
var channel = req.body.channel;
|
var channel = req.body.channel;
|
||||||
db.collection("frontpage_lists").update({_id: channel}, {$set:{thumbnail: ""}}, function(err, docs){
|
db.collection("frontpage_lists").update({_id: channel}, {$set:{thumbnail: ""}}, function(err, docs){
|
||||||
db.collection(channel + "_settings").update({views:{$exists:true}}, {$set:{thumbnail: ""}}, function(err, docs){
|
db.collection(channel + "_settings").update({views:{$exists:true}}, {$set:{thumbnail: ""}}, function(err, docs){
|
||||||
res.send(true);
|
db.collection(channel + "_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;
|
||||||
|
sIO.to(channel).emit("conf", docs);
|
||||||
|
res.send(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -168,7 +199,13 @@ router.route('/api/remove_description').post(function(req, res){
|
|||||||
var channel = req.body.channel;
|
var channel = req.body.channel;
|
||||||
db.collection("frontpage_lists").update({_id: channel}, {$set:{description: ""}}, function(err, docs){
|
db.collection("frontpage_lists").update({_id: channel}, {$set:{description: ""}}, function(err, docs){
|
||||||
db.collection(channel + "_settings").update({views:{$exists:true}}, {$set:{description: ""}}, function(err, docs){
|
db.collection(channel + "_settings").update({views:{$exists:true}}, {$set:{description: ""}}, function(err, docs){
|
||||||
res.send(true);
|
db.collection(channel + "_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;
|
||||||
|
sIO.to(channel).emit("conf", docs);
|
||||||
|
res.send(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -287,9 +324,11 @@ router.route('/api/delete').post(function(req, res){
|
|||||||
if(req.isAuthenticated()){
|
if(req.isAuthenticated()){
|
||||||
var list = req.body._id;
|
var list = req.body._id;
|
||||||
db.collection(list).drop(function(err, docs){
|
db.collection(list).drop(function(err, docs){
|
||||||
db.collection("frontpage_lists").remove({_id: list}, function(err, docs){
|
db.collection(list + "_settings").drop(function(err, docs){
|
||||||
res.send(true);
|
db.collection("frontpage_lists").remove({_id: list}, function(err, docs){
|
||||||
})
|
res.send(true);
|
||||||
|
})
|
||||||
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
res.send(false);
|
res.send(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user