You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
700 B
JavaScript

"use strict";
var async = require('async'),
posts = require('../posts'),
privileges = require('../privileges'),
helpers = require('./helpers'),
postsController = {};
postsController.getPost = function(req, res, next) {
async.parallel({
canRead: function(next) {
privileges.posts.can('read', req.params.pid, req.uid, next);
},
postData: function(next) {
posts.getPostData(req.params.pid, next);
}
}, function(err, results) {
if (err) {
return next(err);
}
if (!results.postData) {
return helpers.notFound(req, res);
}
if (!results.canRead) {
return helpers.notAllowed(req, res);
}
res.json(results.postData);
});
};
module.exports = postsController;