From c9fb5b3e1138cb388015af5798341fa3328c68bb Mon Sep 17 00:00:00 2001 From: barisusakli Date: Mon, 21 Jul 2014 17:43:38 -0400 Subject: [PATCH] changed user posted notification to include title dont send 2 notifications if you are already following topic --- public/language/en_GB/notifications.json | 1 - src/user/notifications.js | 11 +++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/public/language/en_GB/notifications.json b/public/language/en_GB/notifications.json index c6e16c9f55..4f495e87a1 100644 --- a/public/language/en_GB/notifications.json +++ b/public/language/en_GB/notifications.json @@ -11,7 +11,6 @@ "new_notification": "New Notification", "you_have_unread_notifications": "You have unread notifications.", - "user_made_post": "%1 made a new post", "new_message_from": "New message from %1", "upvoted_your_post": "%1 has upvoted your post.", "favourited_your_post": "%1 has favourited your post.", diff --git a/src/user/notifications.js b/src/user/notifications.js index abfcfecf90..d4f1b79708 100644 --- a/src/user/notifications.js +++ b/src/user/notifications.js @@ -156,7 +156,7 @@ var async = require('async'), async.parallel({ 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), postContent: function(next) { async.waterfall([ @@ -165,14 +165,21 @@ var async = require('async'), postTools.parse(content, next); } ], next); + }, + topicFollowers: function(next) { + db.isSetMembers('tid:' + tid + ':followers', followers, next); } }, function(err, results) { if (err) { return; } + followers = followers.filter(function(value, index) { + return !results.topicFollowers[index]; + }); + notifications.create({ - bodyShort: '[[notifications:user_made_post, ' + results.username + ']]', + bodyShort: '[[notifications:user_posted_to, ' + results.username + ', ' + results.topic.title + ']]', bodyLong: results.postContent, path: nconf.get('relative_path') + '/topic/' + results.topic.slug + '/' + results.postIndex, uniqueId: 'topic:' + tid,