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.
33 lines
798 B
JavaScript
33 lines
798 B
JavaScript
10 years ago
|
|
||
|
'use strict';
|
||
|
|
||
|
var cache = require('./cache'),
|
||
|
plugins = require('../plugins');
|
||
|
|
||
|
module.exports = function(Posts) {
|
||
|
|
||
|
Posts.parsePost = function(postData, callback) {
|
||
|
postData.content = postData.content || '';
|
||
|
|
||
|
var cachedContent = cache.get(postData.pid);
|
||
|
if (cachedContent) {
|
||
|
postData.content = cachedContent;
|
||
|
return callback(null, postData);
|
||
|
}
|
||
|
|
||
|
plugins.fireHook('filter:parse.post', {postData: postData}, function(err, data) {
|
||
|
if (err) {
|
||
|
return callback(err);
|
||
|
}
|
||
|
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);
|
||
|
};
|
||
|
};
|