You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nodebb/src/posts/parse.js

41 lines
1010 B
JavaScript

'use strict';
var cache = require('./cache'),
plugins = require('../plugins');
module.exports = function(Posts) {
Posts.parsePost = function(postData, callback) {
postData.content = postData.content || '';
if (postData.pid && cache.has(postData.pid)) {
postData.content = cache.get(postData.pid);
return callback(null, postData);
}
// Casting post content into a string, just in case
if (typeof postData.content !== 'string') {
postData.content = postData.content.toString();
}
plugins.fireHook('filter:parse.post', {postData: postData}, function(err, data) {
if (err) {
return callback(err);
}
9 years ago
if (global.env === 'production' && data.postData.pid) {
9 years ago
cache.set(data.postData.pid, data.postData.content);
}
callback(null, data.postData);
});
};
Posts.parseSignature = function(userData, uid, callback) {
userData.signature = userData.signature || '';
plugins.fireHook('filter:parse.signature', {userData: userData, uid: uid}, callback);
};
};