mirror of
https://github.com/wassname/talk.git
synced 2026-07-27 11:28:12 +08:00
return flagged comments
This commit is contained in:
@@ -56,7 +56,7 @@ router.get('/', (req, res, next) => {
|
||||
.then((ids) => assetIDWrap(Comment.find({
|
||||
id: {
|
||||
$in: ids
|
||||
},
|
||||
}
|
||||
})));
|
||||
} else {
|
||||
query = assetIDWrap(Comment.all());
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user