removedu if from filter:parse,post, parse strip teaser content

v1.18.x
barisusakli 10 years ago
parent 7c9e76132d
commit b268927cf9

@ -120,7 +120,7 @@ var cache = LRU({
},
postData: function(next) {
cache.del(postData.pid);
PostTools.parsePost(postData, data.uid, next);
PostTools.parsePost(postData, next);
}
}, function(err, results) {
if (err) {
@ -176,7 +176,7 @@ var cache = LRU({
if (err) {
return callback(err);
}
PostTools.parsePost(postData, uid, callback);
PostTools.parsePost(postData, callback);
});
}
});
@ -192,7 +192,7 @@ var cache = LRU({
});
};
PostTools.parsePost = function(postData, uid, callback) {
PostTools.parsePost = function(postData, callback) {
postData.content = postData.content || '';
var cachedContent = cache.get(postData.pid);
@ -201,7 +201,7 @@ var cache = LRU({
return callback(null, postData);
}
plugins.fireHook('filter:parse.post', {postData: postData, uid: uid}, function(err, data) {
plugins.fireHook('filter:parse.post', {postData: postData}, function(err, data) {
if (err) {
return callback(err);
}

@ -52,7 +52,7 @@ var async = require('async'),
postData.relativeTime = utils.toISOString(postData.timestamp);
postData.relativeEditTime = parseInt(postData.edited, 10) !== 0 ? utils.toISOString(postData.edited) : '';
postTools.parsePost(postData, uid, next);
postTools.parsePost(postData, next);
}, function(err, posts) {
if (err) {
return callback(err);

@ -86,7 +86,7 @@ module.exports = function(Posts) {
return next(null, post);
}
postTools.parsePost(post, uid, function(err, post) {
postTools.parsePost(post, function(err, post) {
if (err) {
return next(err);
}

@ -232,7 +232,7 @@ SocketPosts.sendNotificationToPostOwner = function(pid, fromuid, notification) {
async.parallel({
username: async.apply(user.getUserField, fromuid, 'username'),
topicTitle: async.apply(topics.getTopicField, postData.tid, 'title'),
postObj: async.apply(postTools.parsePost, postData, postData.uid)
postObj: async.apply(postTools.parsePost, postData)
}, function(err, results) {
if (err) {
return;
@ -479,7 +479,7 @@ SocketPosts.flag = function(socket, pid, callback) {
function(topic, next) {
post.topic = topic;
message = '[[notifications:user_flagged_post_in, ' + userName + ', ' + topic.title + ']]';
postTools.parsePost(post, socket.uid, next);
postTools.parsePost(post, next);
},
function(post, next) {
async.parallel({

@ -245,7 +245,7 @@ module.exports = function(Topics) {
posts.getPidIndex(postData.pid, uid, next);
},
content: function(next) {
postTools.parsePost(postData, uid, next);
postTools.parsePost(postData, next);
}
}, next);
},

@ -3,11 +3,13 @@
'use strict';
var async = require('async'),
S = require('string'),
db = require('../database'),
user = require('../user'),
posts = require('../posts'),
plugins = require('../plugins'),
postTools = require('../postTools'),
utils = require('../../public/src/utils');
@ -49,21 +51,30 @@ module.exports = function(Topics) {
users[user.uid] = user;
});
var tidToPost = {};
postData.forEach(function(post) {
async.each(postData, function(post, next) {
post.user = users[post.uid];
post.timestamp = utils.toISOString(post.timestamp);
tidToPost[post.tid] = post;
});
var teasers = topics.map(function(topic, index) {
if (tidToPost[topic.tid]) {
tidToPost[topic.tid].index = counts[index];
postTools.parsePost(post, next);
}, function(err) {
if (err) {
return callback(err);
}
return tidToPost[topic.tid];
});
plugins.fireHook('filter:teasers.get', {teasers: teasers}, function(err, data) {
callback(err, data ? data.teasers : null);
var teasers = topics.map(function(topic, index) {
if (tidToPost[topic.tid]) {
tidToPost[topic.tid].index = counts[index];
if (tidToPost[topic.tid].content) {
var s = S(tidToPost[topic.tid].content);
tidToPost[topic.tid].content = s.stripTags.apply(s, utils.stripTags).s;
}
}
return tidToPost[topic.tid];
});
plugins.fireHook('filter:teasers.get', {teasers: teasers}, function(err, data) {
callback(err, data ? data.teasers : null);
});
});
});
});

Loading…
Cancel
Save