mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-03-18 01:50:37 +01:00
feat(torrent): add toggleHnRStatus method of admin/oper
This commit is contained in:
@@ -54,6 +54,13 @@
|
||||
torrentId: '@_torrentId'
|
||||
}
|
||||
},
|
||||
toggleHnRStatus: {
|
||||
method: 'PUT',
|
||||
url: '/api/torrents/:torrentId/toggleHnRStatus',
|
||||
params: {
|
||||
torrentId: '@_id'
|
||||
}
|
||||
},
|
||||
thumbsUp: {
|
||||
method: 'PUT',
|
||||
url: '/api/torrents/:torrentId/thumbsUp',
|
||||
|
||||
@@ -486,6 +486,27 @@ exports.scrape = function (req, res) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* toggleHnRStatus
|
||||
* @param req
|
||||
* @param res
|
||||
*/
|
||||
exports.toggleHnRStatus = function (req, res) {
|
||||
var torrent = req.torrent;
|
||||
|
||||
torrent.torrent_hnr = !torrent.torrent_hnr;
|
||||
|
||||
torrent.save(function (err) {
|
||||
if (err) {
|
||||
return res.status(422).send({
|
||||
message: errorHandler.getErrorMessage(err)
|
||||
});
|
||||
} else {
|
||||
res.json(torrent);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* thumbsUp
|
||||
* @param req
|
||||
|
||||
@@ -26,6 +26,7 @@ exports.invokeRolesPolicies = function () {
|
||||
{resources: '/api/torrents/:torrentId', permissions: '*'},
|
||||
{resources: '/api/torrents/:torrentId/thumbsUp', permissions: '*'},
|
||||
{resources: '/api/torrents/:torrentId/scrape', permissions: '*'},
|
||||
{resources: '/api/torrents/:torrentId/toggleHnRStatus', permissions: '*'},
|
||||
{resources: '/api/torrents/:torrentId/set/saletype/:saleType', permissions: '*'},
|
||||
{resources: '/api/torrents/:torrentId/set/recommendlevel/:rlevel', permissions: '*'},
|
||||
{resources: '/api/torrents/:torrentId/set/reviewed', permissions: '*'},
|
||||
|
||||
@@ -41,6 +41,9 @@ module.exports = function (app) {
|
||||
app.route('/api/torrents/:torrentId/scrape').all(torrentsPolicy.isAllowed)
|
||||
.get(torrents.scrape);
|
||||
|
||||
app.route('/api/torrents/:torrentId/toggleHnRStatus').all(torrentsPolicy.isAllowed)
|
||||
.put(torrents.toggleHnRStatus);
|
||||
|
||||
app.route('/api/torrents/:torrentId/set/saletype/:saleType').all(torrentsPolicy.isAllowed)
|
||||
.put(torrents.setSaleType);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user