changed user posted notification to include title

dont send 2 notifications if you are already following topic
v1.18.x
barisusakli 11 years ago
parent 67c5477fb2
commit c9fb5b3e11

@ -11,7 +11,6 @@
"new_notification": "New Notification", "new_notification": "New Notification",
"you_have_unread_notifications": "You have unread notifications.", "you_have_unread_notifications": "You have unread notifications.",
"user_made_post": "<strong>%1</strong> made a new post",
"new_message_from": "New message from <strong>%1</strong>", "new_message_from": "New message from <strong>%1</strong>",
"upvoted_your_post": "<strong>%1</strong> has upvoted your post.", "upvoted_your_post": "<strong>%1</strong> has upvoted your post.",
"favourited_your_post": "<strong>%1</strong> has favourited your post.", "favourited_your_post": "<strong>%1</strong> has favourited your post.",

@ -156,7 +156,7 @@ var async = require('async'),
async.parallel({ async.parallel({
username: async.apply(user.getUserField, uid, 'username'), username: async.apply(user.getUserField, uid, 'username'),
topic: async.apply(topics.getTopicFields, tid, ['slug', 'cid']), topic: async.apply(topics.getTopicFields, tid, ['slug', 'cid', 'title']),
postIndex: async.apply(posts.getPidIndex, pid), postIndex: async.apply(posts.getPidIndex, pid),
postContent: function(next) { postContent: function(next) {
async.waterfall([ async.waterfall([
@ -165,14 +165,21 @@ var async = require('async'),
postTools.parse(content, next); postTools.parse(content, next);
} }
], next); ], next);
},
topicFollowers: function(next) {
db.isSetMembers('tid:' + tid + ':followers', followers, next);
} }
}, function(err, results) { }, function(err, results) {
if (err) { if (err) {
return; return;
} }
followers = followers.filter(function(value, index) {
return !results.topicFollowers[index];
});
notifications.create({ notifications.create({
bodyShort: '[[notifications:user_made_post, ' + results.username + ']]', bodyShort: '[[notifications:user_posted_to, ' + results.username + ', ' + results.topic.title + ']]',
bodyLong: results.postContent, bodyLong: results.postContent,
path: nconf.get('relative_path') + '/topic/' + results.topic.slug + '/' + results.postIndex, path: nconf.get('relative_path') + '/topic/' + results.topic.slug + '/' + results.postIndex,
uniqueId: 'topic:' + tid, uniqueId: 'topic:' + tid,

Loading…
Cancel
Save