Skip to content

Node.js based forum software built for the modern web

parsing the post content that's passed into bodyLong in notifs #1720

Julian Lamd229cd21b258
diff --git a/src/socket.io/posts.js b/src/socket.io/posts.js
index 7c68e8429c..1980d21927 100644
--- a/src/socket.io/posts.js
+++ b/src/socket.io/posts.js
@@ -100,14 +100,16 @@ function sendNotificationToPostOwner(data, uid, notification) {
}
async.parallel({
- username: function(next) {
- user.getUserField(uid, 'username', next);
- },
- topicData: function(next) {
- topics.getTopicFields(postData.tid, ['slug', 'content'], next);
- },
- index: function(next) {
- posts.getPidIndex(data.pid, next);
+ username: async.apply(user.getUserField, uid, 'username'),
+ slug: async.apply(topics.getTopicField, postData.tid, 'slug'),
+ index: async.apply(posts.getPidIndex, data.pid),
+ postContent: function(next) {
+ async.waterfall([
+ async.apply(posts.getPostField, data.pid, 'content'),
+ function(content, next) {
+ postTools.parse(content, next);
+ }
+ ], next);
}
}, function(err, results) {
if (err) {
@@ -116,8 +118,8 @@ function sendNotificationToPostOwner(data, uid, notification) {
notifications.create({
bodyShort: '[[' + notification + ', ' + results.username + ']]',
- bodyLong: results.topicData.content,
- path: nconf.get('relative_path') + '/topic/' + results.topicData.slug + '/' + results.index,
+ bodyLong: results.postContent,
+ path: nconf.get('relative_path') + '/topic/' + results.slug + '/' + results.index,
uniqueId: 'post:' + data.pid,
from: uid
}, function(nid) {
@@ -293,6 +295,12 @@ SocketPosts.flag = function(socket, pid, callback) {
message = '[[notifications:user_flagged_post, ' + username + ']]';
posts.getPostFields(pid, ['tid', 'uid', 'content'], next);
},
+ function(postData, next) {
+ postTools.parse(postData.content, function(err, parsed) {
+ postData.content = parsed;
+ next(undefined, postData);
+ });
+ },
function(postData, next) {
post = postData;
topics.getTopicField(postData.tid, 'slug', next);
diff --git a/src/topics/follow.js b/src/topics/follow.js
index ac08f3fd59..644dde717c 100644
--- a/src/topics/follow.js
+++ b/src/topics/follow.js
@@ -7,6 +7,7 @@ var async = require('async'),
db = require('../database'),
user = require('../user'),
posts = require('../posts'),
+ postTools = require('../postTools'),
notifications = require('../notifications');
module.exports = function(Topics) {
@@ -27,7 +28,14 @@ module.exports = function(Topics) {
topicData: async.apply(Topics.getTopicFields, tid, ['title', 'slug']),
username: async.apply(user.getUserField, exceptUid, 'username'),
postIndex: async.apply(posts.getPidIndex, pid),
- postContent: async.apply(posts.getPostField, pid, 'content')
+ postContent: function(next) {
+ async.waterfall([
+ async.apply(posts.getPostField, pid, 'content'),
+ function(content, next) {
+ postTools.parse(content, next);
+ }
+ ], next);
+ }
}, function(err, results) {
if (err) {
return next(err);
diff --git a/src/user/notifications.js b/src/user/notifications.js
index 935ec26cd4..b1635d3427 100644
--- a/src/user/notifications.js
+++ b/src/user/notifications.js
@@ -10,6 +10,7 @@ var async = require('async'),
db = require('../database'),
notifications = require('../notifications'),
posts = require('../posts'),
+ postTools = require('../postTools'),
topics = require('../topics');
(function(UserNotifications) {
@@ -156,7 +157,14 @@ var async = require('async'),
username: async.apply(user.getUserField, uid, 'username'),
slug: async.apply(topics.getTopicField, tid, 'slug'),
postIndex: async.apply(posts.getPidIndex, pid),
- postContent: async.apply(posts.getPostField, pid, 'content')
+ postContent: function(next) {
+ async.waterfall([
+ async.apply(posts.getPostField, pid, 'content'),
+ function(content, next) {
+ postTools.parse(content, next);
+ }
+ ], next);
+ }
}, function(err, results) {
if (err) {
return;