mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-29 18:16:17 +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) {
|
postData: function(next) {
|
||||||
cache.del(postData.pid);
|
cache.del(postData.pid);
|
||||||
PostTools.parsePost(postData, data.uid, next);
|
PostTools.parsePost(postData, next);
|
||||||
}
|
}
|
||||||
}, function(err, results) {
|
}, function(err, results) {
|
||||||
if (err) {
|
if (err) {
|
||||||
@@ -176,7 +176,7 @@ var cache = LRU({
|
|||||||
if (err) {
|
if (err) {
|
||||||
return callback(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 || '';
|
postData.content = postData.content || '';
|
||||||
|
|
||||||
var cachedContent = cache.get(postData.pid);
|
var cachedContent = cache.get(postData.pid);
|
||||||
@@ -201,7 +201,7 @@ var cache = LRU({
|
|||||||
return callback(null, postData);
|
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) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ var async = require('async'),
|
|||||||
|
|
||||||
postData.relativeTime = utils.toISOString(postData.timestamp);
|
postData.relativeTime = utils.toISOString(postData.timestamp);
|
||||||
postData.relativeEditTime = parseInt(postData.edited, 10) !== 0 ? utils.toISOString(postData.edited) : '';
|
postData.relativeEditTime = parseInt(postData.edited, 10) !== 0 ? utils.toISOString(postData.edited) : '';
|
||||||
postTools.parsePost(postData, uid, next);
|
postTools.parsePost(postData, next);
|
||||||
}, function(err, posts) {
|
}, function(err, posts) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ module.exports = function(Posts) {
|
|||||||
return next(null, post);
|
return next(null, post);
|
||||||
}
|
}
|
||||||
|
|
||||||
postTools.parsePost(post, uid, function(err, post) {
|
postTools.parsePost(post, function(err, post) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -232,7 +232,7 @@ SocketPosts.sendNotificationToPostOwner = function(pid, fromuid, notification) {
|
|||||||
async.parallel({
|
async.parallel({
|
||||||
username: async.apply(user.getUserField, fromuid, 'username'),
|
username: async.apply(user.getUserField, fromuid, 'username'),
|
||||||
topicTitle: async.apply(topics.getTopicField, postData.tid, 'title'),
|
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) {
|
}, function(err, results) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return;
|
return;
|
||||||
@@ -479,7 +479,7 @@ SocketPosts.flag = function(socket, pid, callback) {
|
|||||||
function(topic, next) {
|
function(topic, next) {
|
||||||
post.topic = topic;
|
post.topic = topic;
|
||||||
message = '[[notifications:user_flagged_post_in, ' + userName + ', ' + topic.title + ']]';
|
message = '[[notifications:user_flagged_post_in, ' + userName + ', ' + topic.title + ']]';
|
||||||
postTools.parsePost(post, socket.uid, next);
|
postTools.parsePost(post, next);
|
||||||
},
|
},
|
||||||
function(post, next) {
|
function(post, next) {
|
||||||
async.parallel({
|
async.parallel({
|
||||||
|
|||||||
@@ -245,7 +245,7 @@ module.exports = function(Topics) {
|
|||||||
posts.getPidIndex(postData.pid, uid, next);
|
posts.getPidIndex(postData.pid, uid, next);
|
||||||
},
|
},
|
||||||
content: function(next) {
|
content: function(next) {
|
||||||
postTools.parsePost(postData, uid, next);
|
postTools.parsePost(postData, next);
|
||||||
}
|
}
|
||||||
}, next);
|
}, next);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,11 +3,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var async = require('async'),
|
var async = require('async'),
|
||||||
|
S = require('string'),
|
||||||
|
|
||||||
db = require('../database'),
|
db = require('../database'),
|
||||||
user = require('../user'),
|
user = require('../user'),
|
||||||
posts = require('../posts'),
|
posts = require('../posts'),
|
||||||
plugins = require('../plugins'),
|
plugins = require('../plugins'),
|
||||||
|
postTools = require('../postTools'),
|
||||||
utils = require('../../public/src/utils');
|
utils = require('../../public/src/utils');
|
||||||
|
|
||||||
|
|
||||||
@@ -49,15 +51,23 @@ module.exports = function(Topics) {
|
|||||||
users[user.uid] = user;
|
users[user.uid] = user;
|
||||||
});
|
});
|
||||||
var tidToPost = {};
|
var tidToPost = {};
|
||||||
postData.forEach(function(post) {
|
|
||||||
|
async.each(postData, function(post, next) {
|
||||||
post.user = users[post.uid];
|
post.user = users[post.uid];
|
||||||
post.timestamp = utils.toISOString(post.timestamp);
|
post.timestamp = utils.toISOString(post.timestamp);
|
||||||
tidToPost[post.tid] = post;
|
tidToPost[post.tid] = post;
|
||||||
});
|
postTools.parsePost(post, next);
|
||||||
|
}, function(err) {
|
||||||
|
if (err) {
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
var teasers = topics.map(function(topic, index) {
|
var teasers = topics.map(function(topic, index) {
|
||||||
if (tidToPost[topic.tid]) {
|
if (tidToPost[topic.tid]) {
|
||||||
tidToPost[topic.tid].index = counts[index];
|
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];
|
return tidToPost[topic.tid];
|
||||||
});
|
});
|
||||||
@@ -67,6 +77,7 @@ module.exports = function(Topics) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Topics.getTeasersByTids = function(tids, callback) {
|
Topics.getTeasersByTids = function(tids, callback) {
|
||||||
|
|||||||
Reference in New Issue
Block a user