mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-02-27 08:40:57 +01:00
feat(forums): new feature for oper & admin can set topic to show as home help item or home notice item
#20
This commit is contained in:
@@ -454,7 +454,7 @@ exports.updateTopic = function (req, res) {
|
||||
|
||||
if (!canEdit(req.user, forum) && !isOwner(req.user, topic)) {
|
||||
return res.status(403).json({
|
||||
message: 'ERROR: User is not authorized'
|
||||
message: 'SERVER.USER_IS_NOT_AUTHORIZED'
|
||||
});
|
||||
}
|
||||
|
||||
@@ -485,7 +485,7 @@ exports.toggleTopicReadonly = function (req, res) {
|
||||
|
||||
if (!canEdit(req.user, forum) && !isOwner(req.user, topic)) {
|
||||
return res.status(403).json({
|
||||
message: 'ERROR: User is not authorized'
|
||||
message: 'SERVER.USER_IS_NOT_AUTHORIZED'
|
||||
});
|
||||
}
|
||||
|
||||
@@ -513,7 +513,7 @@ exports.toggleTopicTopStatus = function (req, res) {
|
||||
|
||||
if (!canEdit(req.user, forum)) {
|
||||
return res.status(403).json({
|
||||
message: 'ERROR: User is not authorized'
|
||||
message: 'SERVER.USER_IS_NOT_AUTHORIZED'
|
||||
});
|
||||
}
|
||||
|
||||
@@ -540,7 +540,7 @@ exports.toggleTopicGlobalStatus = function (req, res) {
|
||||
|
||||
if (!req.user.isOper && !req.user.isAdmin) {
|
||||
return res.status(403).json({
|
||||
message: 'ERROR: User is not authorized'
|
||||
message: 'SERVER.USER_IS_NOT_AUTHORIZED'
|
||||
});
|
||||
}
|
||||
|
||||
@@ -557,6 +557,60 @@ exports.toggleTopicGlobalStatus = function (req, res) {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* toggleTopicHomeHelpStatus
|
||||
* @param req
|
||||
* @param res
|
||||
*/
|
||||
exports.toggleTopicHomeHelpStatus = function (req, res) {
|
||||
var topic = req.topic;
|
||||
|
||||
if (!req.user.isOper && !req.user.isAdmin) {
|
||||
return res.status(403).json({
|
||||
message: 'SERVER.USER_IS_NOT_AUTHORIZED'
|
||||
});
|
||||
}
|
||||
|
||||
topic.isHomeHelp = !topic.isHomeHelp;
|
||||
|
||||
topic.save(function (err) {
|
||||
if (err) {
|
||||
return res.status(422).send({
|
||||
message: errorHandler.getErrorMessage(err)
|
||||
});
|
||||
} else {
|
||||
res.json(topic);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* toggleTopicHomeNoticeStatus
|
||||
* @param req
|
||||
* @param res
|
||||
*/
|
||||
exports.toggleTopicHomeNoticeStatus = function (req, res) {
|
||||
var topic = req.topic;
|
||||
|
||||
if (!req.user.isOper && !req.user.isAdmin) {
|
||||
return res.status(403).json({
|
||||
message: 'SERVER.USER_IS_NOT_AUTHORIZED'
|
||||
});
|
||||
}
|
||||
|
||||
topic.isHomeNotice = !topic.isHomeNotice;
|
||||
|
||||
topic.save(function (err) {
|
||||
if (err) {
|
||||
return res.status(422).send({
|
||||
message: errorHandler.getErrorMessage(err)
|
||||
});
|
||||
} else {
|
||||
res.json(topic);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* thumbsUp
|
||||
* @param req
|
||||
@@ -681,7 +735,7 @@ exports.deleteTopic = function (req, res) {
|
||||
|
||||
if (!canEdit(req.user, forum) && !isOwner(req.user, topic)) {
|
||||
return res.status(403).json({
|
||||
message: 'ERROR: User is not authorized'
|
||||
message: 'SERVER.USER_IS_NOT_AUTHORIZED'
|
||||
});
|
||||
}
|
||||
|
||||
@@ -824,7 +878,7 @@ exports.updateReply = function (req, res) {
|
||||
|
||||
if (!canEdit(req.user, forum) && !isOwner(req.user, r)) {
|
||||
return res.status(403).json({
|
||||
message: 'ERROR: User is not authorized'
|
||||
message: 'SERVER.USER_IS_NOT_AUTHORIZED'
|
||||
});
|
||||
}
|
||||
|
||||
@@ -861,7 +915,7 @@ exports.deleteReply = function (req, res) {
|
||||
|
||||
if (!canEdit(req.user, forum) && !isOwner(req.user, r)) {
|
||||
return res.status(403).json({
|
||||
message: 'ERROR: User is not authorized'
|
||||
message: 'SERVER.USER_IS_NOT_AUTHORIZED'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user