mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-07-28 18:40:25 +02:00
feat(forums): new server notice message of forum topic has new reply and thumbs up
#20
This commit is contained in:
5
config/env/torrents.js
vendored
5
config/env/torrents.js
vendored
@@ -331,7 +331,10 @@ module.exports = {
|
||||
makerCreate: {title: 'TITLE_MAKER_CREATE', content: 'CONTENT_MAKER_CREATE', enable: true},
|
||||
vipStatusChanged: {title: 'TITLE_VIP_CHANGED_ADD', content: 'CONTENT_VIP_CHANGED_ADD', enable: true},
|
||||
hnrWarningAddByAnnounce: {title: 'TITLE_HNR_WARNING_ADD', content: 'CONTENT_HNR_WARNING_ADD', enable: true},
|
||||
hnrWarningRemoveByAnnounce: {title: 'TITLE_HNR_WARNING_REMOVE', content: 'CONTENT_HNR_WARNING_REMOVE', enable: true}
|
||||
hnrWarningRemoveByAnnounce: {title: 'TITLE_HNR_WARNING_REMOVE', content: 'CONTENT_HNR_WARNING_REMOVE', enable: true},
|
||||
forumTopicNewReply: {title: 'TITLE_FORUM_NEW_TOPIC_REPLY', content: 'CONTENT_FORUM_NEW_TOPIC_REPLY', enable: true},
|
||||
forumTopicThumbsUp: {title: 'TITLE_FORUM_TOPIC_THUMBS_UP', content: 'CONTENT_FORUM_TOPIC_THUMBS_UP', enable: true},
|
||||
forumReplyThumbsUp: {title: 'TITLE_FORUM_REPLY_THUMBS_UP', content: 'CONTENT_FORUM_REPLY_THUMBS_UP', enable: true}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
'use strict';
|
||||
|
||||
var mongoose = require('mongoose'),
|
||||
var path = require('path'),
|
||||
config = require(path.resolve('./config/config')),
|
||||
mongoose = require('mongoose'),
|
||||
Message = mongoose.model('Message');
|
||||
|
||||
var mtDebug = require(path.resolve('./config/lib/debug'));
|
||||
|
||||
module.exports.addMessage = function (uid, title, content, params) {
|
||||
if (uid && mongoose.Types.ObjectId.isValid(uid)) {
|
||||
@@ -21,6 +24,8 @@ module.exports.addMessage = function (uid, title, content, params) {
|
||||
to_status: 0
|
||||
});
|
||||
|
||||
mtDebug.debugGreen(msg);
|
||||
|
||||
msg.save();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1294,9 +1294,18 @@
|
||||
CONTENT_MAKER_CREATE: 'Administrator already created a maker group **-={{maker_group_name}}=-** for you, you are the group founder now, Thank you for your contribution on **{{site_name}}** :100:',
|
||||
|
||||
TITLE_HNR_WARNING_ADD: 'New H&R warning',
|
||||
CONTENT_HNR_WARNING_ADD: '###H&R warning! \n You just got a h&r warning on torrent [{{torrent_file_name}}](/torrents/{{torrent_id}}), please continue to seeding, the warning will be auto cleanup when the seed ratio more than {{hnr_ratio}} or seed time more than {{hnr_days}} days or clean up manually at [warning list](/status/warning).',
|
||||
CONTENT_HNR_WARNING_ADD: '### H&R warning! \n You just got a h&r warning on torrent [{{torrent_file_name}}](/torrents/{{torrent_id}}), please continue to seeding, the warning will be auto cleanup when the seed ratio more than {{hnr_ratio}} or seed time more than {{hnr_days}} days or clean up manually at [warning list](/status/warning).',
|
||||
TITLE_HNR_WARNING_REMOVE: 'H&R warning removed',
|
||||
CONTENT_HNR_WARNING_REMOVE: '###H&R warning removed! \n Congratulate, your h&r warning ont torrent [{{torrent_file_name}}](/torrents/{{torrent_id}}) already clean up.'
|
||||
CONTENT_HNR_WARNING_REMOVE: '### H&R warning removed! \n Congratulate, your h&r warning ont torrent [{{torrent_file_name}}](/torrents/{{torrent_id}}) already clean up.',
|
||||
|
||||
TITLE_FORUM_NEW_TOPIC_REPLY: 'Topic in forum has new reply',
|
||||
CONTENT_FORUM_NEW_TOPIC_REPLY: '### New reply! \n :collision: Your posted topic in forum [{{topic_title}}](/forums/{{forum_id}}/{{topic_id}}#{{reply_id}}) has new reply by user [{{by_name}}](/userinfo/{{by_id}})',
|
||||
|
||||
TITLE_FORUM_TOPIC_THUMBS_UP: 'Topic in forum was be thumbs up',
|
||||
CONTENT_FORUM_TOPIC_THUMBS_UP: '### Thumbs up! \n :+1: Your posted topic [{{topic_title}}](/forums/{{forum_id}}/{{topic_id}}) in forum was be thumbs up by user [{{by_name}}](/userinfo/{{by_id}})',
|
||||
|
||||
TITLE_FORUM_REPLY_THUMBS_UP: 'Reply in forum was be thumbs up',
|
||||
CONTENT_FORUM_REPLY_THUMBS_UP: '### Thumbs up! \n :+1: Your posted reply of topic [{{topic_title}}](/forums/{{forum_id}}/{{topic_id}}#{{reply_id}}) in forum was be thumbs up by user [{{by_name}}](/userinfo/{{by_id}})'
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1294,9 +1294,18 @@
|
||||
CONTENT_MAKER_CREATE: '管理员已为您创建资源制作小组 **-={{maker_group_name}}=-** , 您现在是该小组的创建人, 感谢您为 **{{site_name}}** 所做的贡献! :100:',
|
||||
|
||||
TITLE_HNR_WARNING_ADD: '新的 H&R 警告',
|
||||
CONTENT_HNR_WARNING_ADD: '###H&R 警告! \n 您刚刚得到一个 h&r 警告在种子 [{{torrent_file_name}}](/torrents/{{torrent_id}}), 您需要继续做种, 这个警告会在该种分享率大于 {{hnr_ratio}} 或做种时间大于 {{hnr_days}} 天时自动清除,您也可以从这里 [warning list](/status/warning) 使用系统积分手动清除.',
|
||||
CONTENT_HNR_WARNING_ADD: '### H&R 警告! \n 您刚刚得到一个 h&r 警告在种子 [{{torrent_file_name}}](/torrents/{{torrent_id}}), 您需要继续做种, 这个警告会在该种分享率大于 {{hnr_ratio}} 或做种时间大于 {{hnr_days}} 天时自动清除,您也可以从这里 [warning list](/status/warning) 使用系统积分手动清除.',
|
||||
TITLE_HNR_WARNING_REMOVE: 'H&R 警告移除',
|
||||
CONTENT_HNR_WARNING_REMOVE: '###H&R 警告已移除! \n 恭喜您, 您在种子 [{{torrent_file_name}}](/torrents/{{torrent_id}}) 上的 h&r 警告已经移除.'
|
||||
CONTENT_HNR_WARNING_REMOVE: '### H&R 警告已移除! \n 恭喜您, 您在种子 [{{torrent_file_name}}](/torrents/{{torrent_id}}) 上的 h&r 警告已经移除.',
|
||||
|
||||
TITLE_FORUM_NEW_TOPIC_REPLY: '论坛主题有了新回复',
|
||||
CONTENT_FORUM_NEW_TOPIC_REPLY: '### 新回复! \n :collision: 您在论坛发表的主题 [{{topic_title}}](/forums/{{forum_id}}/{{topic_id}}) 有了一个新回复来自用户 [{{by_name}}](/userinfo/{{by_id}})',
|
||||
|
||||
TITLE_FORUM_TOPIC_THUMBS_UP: '论坛主题被点赞',
|
||||
CONTENT_FORUM_TOPIC_THUMBS_UP: '### 点赞! \n :+1: 您在论坛发表的主题 [{{topic_title}}](/forums/{{forum_id}}/{{topic_id}}) 收到一个点赞来自用户 [{{by_name}}](/userinfo/{{by_id}})',
|
||||
|
||||
TITLE_FORUM_REPLY_THUMBS_UP: '论坛回复被点赞',
|
||||
CONTENT_FORUM_REPLY_THUMBS_UP: '### 点赞! \n :+1: 您在论坛主题 [{{topic_title}}](/forums/{{forum_id}}/{{topic_id}}#{{reply_id}}) 发表的回复收到一个点赞来自用户 [{{by_name}}](/userinfo/{{by_id}})'
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@ var path = require('path'),
|
||||
|
||||
var traceConfig = config.meanTorrentConfig.trace;
|
||||
var thumbsUpScore = config.meanTorrentConfig.score.thumbsUpScore;
|
||||
var serverMessage = require(path.resolve('./config/lib/server-message'));
|
||||
var serverNoticeConfig = config.meanTorrentConfig.serverNotice;
|
||||
|
||||
var mtDebug = require(path.resolve('./config/lib/debug'));
|
||||
|
||||
@@ -564,15 +566,18 @@ exports.thumbsUp = function (req, res) {
|
||||
var user = req.user;
|
||||
var exist = false;
|
||||
var topic = req.topic;
|
||||
var replyUid = undefined;
|
||||
var thumb = new Thumb();
|
||||
thumb.user = req.user;
|
||||
thumb.score = thumbsUpScore.topic;
|
||||
|
||||
|
||||
if (req.query.replyId) {
|
||||
topic._replies.forEach(function (r) {
|
||||
if (r._id.equals(req.query.replyId)) {
|
||||
//check if already exist
|
||||
exist = false;
|
||||
replyUid = r.user._id;
|
||||
r._thumbs.forEach(function (sr) {
|
||||
if (sr.user._id.equals(req.user._id)) {
|
||||
exist = true;
|
||||
@@ -589,6 +594,18 @@ exports.thumbsUp = function (req, res) {
|
||||
$inc: {score: thumbsUpScore.topic}
|
||||
}).exec();
|
||||
save();
|
||||
|
||||
//add server message
|
||||
if (serverNoticeConfig.action.forumReplyThumbsUp.enable) {
|
||||
serverMessage.addMessage(replyUid, serverNoticeConfig.action.forumReplyThumbsUp.title, serverNoticeConfig.action.forumReplyThumbsUp.content, {
|
||||
topic_title: topic.title,
|
||||
forum_id: topic.forum,
|
||||
topic_id: topic._id,
|
||||
reply_id: req.query.replyId,
|
||||
by_name: user.displayName,
|
||||
by_id: user._id
|
||||
});
|
||||
}
|
||||
} else {
|
||||
return res.status(422).send({
|
||||
message: 'SERVER.SCORE_NOT_ENOUGH'
|
||||
@@ -616,6 +633,17 @@ exports.thumbsUp = function (req, res) {
|
||||
$inc: {score: thumbsUpScore.topic}
|
||||
}).exec();
|
||||
save();
|
||||
|
||||
//add server message
|
||||
if (serverNoticeConfig.action.forumTopicThumbsUp.enable) {
|
||||
serverMessage.addMessage(topic.user._id, serverNoticeConfig.action.forumTopicThumbsUp.title, serverNoticeConfig.action.forumTopicThumbsUp.content, {
|
||||
topic_title: topic.title,
|
||||
forum_id: topic.forum,
|
||||
topic_id: topic._id,
|
||||
by_name: user.displayName,
|
||||
by_id: user._id
|
||||
});
|
||||
}
|
||||
} else {
|
||||
return res.status(422).send({
|
||||
message: 'SERVER.SCORE_NOT_ENOUGH'
|
||||
@@ -755,6 +783,18 @@ exports.postNewReply = function (req, res) {
|
||||
$inc: {replyCount: 1},
|
||||
lastTopic: topic
|
||||
}).exec();
|
||||
|
||||
//add server message
|
||||
if (serverNoticeConfig.action.forumTopicNewReply.enable && !topic.user._id.equals(user._id)) {
|
||||
serverMessage.addMessage(topic.user._id, serverNoticeConfig.action.forumTopicNewReply.title, serverNoticeConfig.action.forumTopicNewReply.content, {
|
||||
topic_title: topic.title,
|
||||
forum_id: topic.forum,
|
||||
topic_id: topic._id,
|
||||
reply_id: reply._id,
|
||||
by_name: user.displayName,
|
||||
by_id: user._id
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user