mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-03-06 12:11:02 +01:00
feat(forums): topic owner or oper can edit topic content now
This commit is contained in:
@@ -57,7 +57,7 @@ exports.listTopics = function (req, res) {
|
||||
Topic.find({
|
||||
forum: req.params.forumId
|
||||
})
|
||||
.sort('-isTop -updatedAt -createdAt')
|
||||
.sort('-isTop -createdAt')
|
||||
.populate('user', 'username displayName profileImageURL uploaded downloaded')
|
||||
.populate('lastUser', 'username displayName profileImageURL uploaded downloaded')
|
||||
.exec(function (err, topics) {
|
||||
@@ -98,7 +98,7 @@ exports.postNewTopic = function (req, res) {
|
||||
};
|
||||
|
||||
/**
|
||||
* read forum
|
||||
* read readTopic
|
||||
* @param req
|
||||
* @param res
|
||||
*/
|
||||
@@ -106,6 +106,30 @@ exports.readTopic = function (req, res) {
|
||||
res.json(req.topic);
|
||||
};
|
||||
|
||||
/**
|
||||
* updateTopic
|
||||
* @param req
|
||||
* @param res
|
||||
*/
|
||||
exports.updateTopic = function (req, res) {
|
||||
var forum = req.forum;
|
||||
var topic = req.topic;
|
||||
|
||||
topic.content = req.body.content;
|
||||
topic.updatedAt = Date.now();
|
||||
topic.updatedBy = req.user;
|
||||
|
||||
topic.save(function (err) {
|
||||
if (err) {
|
||||
return res.status(422).send({
|
||||
message: errorHandler.getErrorMessage(err)
|
||||
});
|
||||
} else {
|
||||
res.json(topic);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Invitation middleware
|
||||
*/
|
||||
@@ -120,6 +144,7 @@ exports.topicById = function (req, res, next, id) {
|
||||
Topic.findById(id)
|
||||
.populate('user', 'username displayName profileImageURL uploaded downloaded score')
|
||||
.populate('lastUser', 'username displayName profileImageURL uploaded downloaded')
|
||||
.populate('updatedBy', 'username displayName profileImageURL uploaded downloaded')
|
||||
.populate('_scoreList.user', 'username displayName profileImageURL uploaded downloaded')
|
||||
.populate('_replies.user', 'username displayName profileImageURL uploaded downloaded')
|
||||
.exec(function (err, topic) {
|
||||
|
||||
Reference in New Issue
Block a user