return flagged comments

This commit is contained in:
Riley Davis
2017-01-12 13:44:10 -07:00
parent f1272338cd
commit b66efb7f2a
2 changed files with 15 additions and 5 deletions
+1 -1
View File
@@ -56,7 +56,7 @@ router.get('/', (req, res, next) => {
.then((ids) => assetIDWrap(Comment.find({
id: {
$in: ids
},
}
})));
} else {
query = assetIDWrap(Comment.all());
+14 -4
View File
@@ -58,10 +58,20 @@ router.get('/comments/rejected', /*authorization.needed('admin'),*/ (req, res, n
router.get('/comments/flagged', authorization.needed('admin'), (req, res, next) => {
const {asset_id} = req.query;
Comment.findIdsByActionType('flagged')
.then(ids => {
console.log(ids);
res.json(ids);
const assetIDWrap = (query) => {
if (asset_id) {
query = query.where('asset_id', asset_id);
}
return query;
};
Comment.findIdsByActionType('flag')
.then(ids => assetIDWrap(Comment.find({
id: { $in: ids }
})))
.then(([comments, users, actions]) => {
res.json({comments, users, actions});
})
.catch(error => {
next(error);