Merge branch 'master' into csrf

This commit is contained in:
gaba
2016-12-22 14:23:01 -08:00
56 changed files with 1802 additions and 7840 deletions
+12 -4
View File
@@ -104,7 +104,7 @@ router.post('/', parseForm, csrfProtection, wordlist.filter('body'), (req, res,
// premod, set it to `premod`.
let status;
if (req.wordlist.matched) {
if (req.wordlist.banned) {
status = Promise.resolve('rejected');
} else {
status = Asset
@@ -142,6 +142,15 @@ router.post('/', parseForm, csrfProtection, wordlist.filter('body'), (req, res,
status,
author_id: req.user.id
}))
.then((comment) => {
if (req.wordlist.suspect) {
return Comment
.addAction(comment.id, null, 'flag', 'body', 'Matched suspect word filters.')
.then(() => comment);
}
return comment;
})
.then((comment) => {
// The comment was created! Send back the created comment.
@@ -198,12 +207,11 @@ router.post('/:comment_id/actions', parseForm, csrfProtection, (req, res, next)
const {
action_type,
field,
detail
metadata
} = req.body;
Comment
.addAction(req.params.comment_id, req.user.id, action_type, field, detail)
.addAction(req.params.comment_id, req.user.id, action_type, metadata)
.then((action) => {
res.status(201).json(action);
})