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

v1.18.x
Julian Lam 11 years ago
parent f9b5bf83ad
commit d229cd21b2

@ -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);

@ -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);

@ -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;

Loading…
Cancel
Save