Added status changing + history

- Status's for comments is now an array of objects
This commit is contained in:
Wyatt Johnson
2016-12-05 11:28:27 -05:00
parent 5485a446f3
commit 2f7f0249b2
22 changed files with 694 additions and 312 deletions
+33 -7
View File
@@ -1,6 +1,7 @@
const express = require('express');
const Comment = require('../../../models/comment');
const Setting = require('../../../models/setting');
const Asset = require('../../../models/asset');
const router = express.Router();
@@ -13,14 +14,39 @@ const router = express.Router();
// Pre-moderation: New comments are shown in the moderator queues immediately.
// Post-moderation: New comments do not appear in moderation queues unless they are flagged by other users.
router.get('/comments/pending', (req, res, next) => {
Setting.getModerationSetting().then(function({moderation}){
Comment.moderationQueue(moderation).then((comments) => {
res.status(200).json(comments);
const {
asset_id
} = req.query;
let settings = Setting.retrieve();
if (asset_id) {
// In the event that we have an asset_id, we should fetch the asset settings
// in order to actually determine if there is additional comments to parse.
settings = Promise.all([
settings,
Asset.findById(asset_id).select('settings')
]).then(([{moderation}, asset]) => {
if (asset.settings && asset.settings.moderation) {
return {moderation: asset.settings.moderation};
}
return {moderation};
});
}
settings
.then(({moderation}) => {
return Comment.moderationQueue(moderation);
}).then((comments) => {
res.json(comments);
})
.catch(error => {
next(error);
});
})
.catch(error => {
next(error);
});
});
module.exports = router;