feat(torrents): irc announce message when torrent reviewed by oper/admin

This commit is contained in:
OldHawk
2017-08-03 11:21:29 +08:00
parent 72b3d77bc6
commit 4ae40c6090
2 changed files with 29 additions and 6 deletions

View File

@@ -29,7 +29,8 @@ module.exports = {
userName: 'meanTorrent',
realName: 'IRC announce client',
channel: '#chdAnnounce',
msg_format: '%s upload torrent %s at %s',
default_msg_format: '%s upload - torrent: %s, type: %s, size: %d, sale: %s, at %s',
tvserial_msg_format: '%s upload - torrent: %s, type: %s, size: %d, seasons: %d, episodes: %s, sale: %s, at %s',
showErrors: true,
autoRejoin: true,
autoConnect: true,

View File

@@ -570,11 +570,6 @@ exports.setRecommendLevel = function (req, res) {
});
}
});
var client = req.app.get('ircClient');
var msg = vsprintf(ircConfig.msg_format, [torrent.user.displayName, torrent.torrent_filename, moment().format('YYYY-MM-DD HH:mm:ss')]);
client.notice(ircConfig.channel, msg);
} else {
return res.status(422).send({
message: 'params rlevel error'
@@ -601,6 +596,33 @@ exports.setReviewedStatus = function (req, res) {
} else {
res.json(torrent);
//irc announce
var msg = '';
var client = req.app.get('ircClient');
if (torrent.torrent_type === 'tvserial') {
msg = vsprintf(ircConfig.tvserial_msg_format, [
torrent.user.displayName,
torrent.torrent_filename,
torrent.torrent_type,
torrent.torrent_size,
torrent.torrent_seasons,
torrent.torrent_episodes,
torrent.torrent_sale_status,
moment().format('YYYY-MM-DD HH:mm:ss')
]);
} else {
msg = vsprintf(ircConfig.default_msg_format, [
torrent.user.displayName,
torrent.torrent_filename,
torrent.torrent_type,
torrent.torrent_size,
torrent.torrent_sale_status,
moment().format('YYYY-MM-DD HH:mm:ss')
]);
}
client.notice(ircConfig.channel, msg);
//create trace log
traceLogCreate(req, traceConfig.action.AdminTorrentSetReviewedStatus, {
torrent: torrent._id,