feat(forums): post new topic

This commit is contained in:
OldHawk
2017-07-07 17:19:42 +08:00
parent 18b2512037
commit ffd2ff406a
9 changed files with 113 additions and 31 deletions

View File

@@ -65,3 +65,25 @@ exports.listTopics = function (req, res) {
res.json(topics);
});
};
/**
* postNewTopic
* @param req
* @param res
*/
exports.postNewTopic = function (req, res) {
var forum = req.forum;
var topic = new Topic(req.body);
topic.forum = forum;
topic.user = req.user;
topic.save(function (err) {
if (err) {
return res.status(422).send({
message: errorHandler.getErrorMessage(err)
});
} else {
res.json(topic);
}
});
};