mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-28 09:36:16 +01:00
removedu if from filter:parse,post, parse strip teaser content
This commit is contained in:
@@ -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,15 +51,23 @@ 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;
|
||||
});
|
||||
|
||||
postTools.parsePost(post, next);
|
||||
}, function(err) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
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];
|
||||
});
|
||||
@@ -67,6 +77,7 @@ module.exports = function(Topics) {
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Topics.getTeasersByTids = function(tids, callback) {
|
||||
|
||||
Reference in New Issue
Block a user