Merge branch 'master' into asset-settings

This commit is contained in:
Wyatt Johnson
2016-11-28 17:16:39 -07:00
13 changed files with 43 additions and 94 deletions
+1 -3
View File
@@ -1,6 +1,5 @@
const express = require('express');
const Setting = require('../../../models/setting');
const _ = require('lodash');
const router = express.Router();
@@ -8,8 +7,7 @@ router.get('/', (req, res, next) => {
Setting
.getSettings()
.then(settings => {
const whitelist = ['moderation'];
res.json(_.pick(settings, whitelist));
res.json(settings);
})
.catch(next);
});
+2 -6
View File
@@ -14,7 +14,6 @@ router.get('/', (req, res, next) => {
// Get the asset_id for this url (or create it if it doesn't exist)
Promise.all([
// Find or create the asset by url.
Asset.findOrCreateByUrl(decodeURIComponent(req.query.asset_url))
@@ -38,14 +37,12 @@ router.get('/', (req, res, next) => {
settings = Object.assign(settings, asset.settings);
}
// Fetch the appropriate comments stream.
// Fetch the appropriate comments stream.
let comments;
if (settings.moderation === 'post') {
comments = Comment.findAcceptedByAssetId(asset.id);
} else {
// Defaults to 'pre' moderation.
comments = Comment.findAcceptedAndNewByAssetId(asset.id);
}
@@ -93,7 +90,7 @@ router.get('/', (req, res, next) => {
// It's comments...
comments,
// All the users/authors of those comments...
// The users who wrote those comments
users,
// And all actions about the asset, comments, and users.
@@ -104,7 +101,6 @@ router.get('/', (req, res, next) => {
]);
})
.then(([asset, comments, users, actions, settings]) => {
// Send back the payload containing all this data.
res.json({
assets: [asset],