mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-28 17:46:16 +01:00
closes #2303
see https://community.nodebb.org/topic/3039/filter-post-parse-and-filter-post-parsesignature-changes
This commit is contained in:
@@ -173,7 +173,7 @@ accountsController.getAccount = function(req, res, next) {
|
||||
posts.getPostsByUid(callerUID, userData.theirid, 0, 9, next);
|
||||
},
|
||||
signature: function(next) {
|
||||
postTools.parseSignature(userData.signature, next);
|
||||
postTools.parseSignature(userData, callerUID, next);
|
||||
}
|
||||
}, function(err, results) {
|
||||
if(err) {
|
||||
@@ -191,7 +191,6 @@ accountsController.getAccount = function(req, res, next) {
|
||||
userData.profileviews = 1;
|
||||
}
|
||||
|
||||
userData.signature = results.signature;
|
||||
res.render('account/profile', userData);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -163,7 +163,7 @@ var db = require('./database'),
|
||||
}
|
||||
|
||||
Messaging.parse = function (message, fromuid, myuid, toUserData, myUserData, isNew, callback) {
|
||||
plugins.fireHook('filter:post.parse', message, function(err, parsed) {
|
||||
plugins.fireHook('filter:parse.raw', message, function(err, parsed) {
|
||||
if (err) {
|
||||
return callback(message);
|
||||
}
|
||||
|
||||
@@ -93,14 +93,14 @@ var winston = require('winston'),
|
||||
});
|
||||
});
|
||||
},
|
||||
content: function(next) {
|
||||
PostTools.parse(postData.content, next);
|
||||
postData: function(next) {
|
||||
PostTools.parsePost(postData, uid, next);
|
||||
}
|
||||
}, function(err, results) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
results.content = results.postData.content;
|
||||
//events.logPostEdit(uid, pid);
|
||||
plugins.fireHook('action:post.edit', postData);
|
||||
callback(null, results);
|
||||
@@ -137,7 +137,7 @@ var winston = require('winston'),
|
||||
next();
|
||||
}
|
||||
], function(err) {
|
||||
if(err) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
@@ -149,13 +149,7 @@ var winston = require('winston'),
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
PostTools.parse(postData.content, function(err, parsed) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
postData.content = parsed;
|
||||
callback(null, postData);
|
||||
});
|
||||
PostTools.parsePost(postData, uid, callback);
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -171,20 +165,18 @@ var winston = require('winston'),
|
||||
});
|
||||
};
|
||||
|
||||
PostTools.parse = function(raw, callback) {
|
||||
parse('filter:post.parse', raw + '\n', callback);
|
||||
};
|
||||
PostTools.parsePost = function(postData, uid, callback) {
|
||||
postData.content = postData.content || '';
|
||||
|
||||
PostTools.parseSignature = function(raw, callback) {
|
||||
parse('filter:post.parseSignature', raw, callback);
|
||||
};
|
||||
|
||||
function parse(hook, raw, callback) {
|
||||
raw = raw || '';
|
||||
|
||||
plugins.fireHook(hook, raw, function(err, parsed) {
|
||||
callback(null, !err ? parsed : raw);
|
||||
plugins.fireHook('filter:parse.post', {postData: postData, uid: uid}, function(err, data) {
|
||||
callback(err, data ? data.postData : null);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
PostTools.parseSignature = function(userData, uid, callback) {
|
||||
userData.signature = userData.signature || '';
|
||||
|
||||
plugins.fireHook('filter:parse.signature', {userData: userData, uid: uid}, callback);
|
||||
};
|
||||
|
||||
}(exports));
|
||||
|
||||
21
src/posts.js
21
src/posts.js
@@ -146,16 +146,7 @@ var async = require('async'),
|
||||
|
||||
postData.relativeTime = utils.toISOString(postData.timestamp);
|
||||
postData.relativeEditTime = parseInt(postData.edited, 10) !== 0 ? utils.toISOString(postData.edited) : '';
|
||||
|
||||
postTools.parse(postData.content, function(err, content) {
|
||||
if(err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
postData.content = content;
|
||||
next(null, postData);
|
||||
});
|
||||
|
||||
postTools.parsePost(postData, uid, next);
|
||||
}, function(err, posts) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
@@ -176,7 +167,7 @@ var async = require('async'),
|
||||
});
|
||||
};
|
||||
|
||||
Posts.getUserInfoForPosts = function(uids, callback) {
|
||||
Posts.getUserInfoForPosts = function(uids, uid, callback) {
|
||||
async.parallel({
|
||||
groups: function(next) {
|
||||
groups.getUserGroups(uids, next);
|
||||
@@ -212,7 +203,7 @@ var async = require('async'),
|
||||
if (parseInt(meta.config.disableSignatures, 10) === 1) {
|
||||
return next();
|
||||
}
|
||||
postTools.parseSignature(userData.signature, next);
|
||||
postTools.parseSignature(userData, uid, next);
|
||||
},
|
||||
customProfileInfo: function(next) {
|
||||
plugins.fireHook('filter:posts.custom_profile_info', {profile: [], uid: userData.uid}, next);
|
||||
@@ -221,7 +212,7 @@ var async = require('async'),
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
userData.signature = results.signature;
|
||||
|
||||
userData.custom_profile_info = results.customProfileInfo.profile;
|
||||
|
||||
plugins.fireHook('filter:posts.modifyUserInfo', userData, next);
|
||||
@@ -335,12 +326,12 @@ var async = require('async'),
|
||||
return next(null, post);
|
||||
}
|
||||
|
||||
postTools.parse(post.content, function(err, content) {
|
||||
postTools.parsePost(post, uid, function(err, post) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
post.content = stripTags(content);
|
||||
post.content = stripTags(post.content);
|
||||
|
||||
next(null, post);
|
||||
});
|
||||
|
||||
@@ -73,7 +73,7 @@ SocketModules.composer.editCheck = function(socket, pid, callback) {
|
||||
};
|
||||
|
||||
SocketModules.composer.renderPreview = function(socket, content, callback) {
|
||||
plugins.fireHook('filter:post.parse', content, callback);
|
||||
plugins.fireHook('filter:parse.raw', content, callback);
|
||||
};
|
||||
|
||||
SocketModules.composer.renderHelp = function(socket, data, callback) {
|
||||
@@ -83,7 +83,7 @@ SocketModules.composer.renderHelp = function(socket, data, callback) {
|
||||
return callback(new Error('help-hidden'));
|
||||
}
|
||||
|
||||
plugins.fireHook('filter:post.parse', helpText, function(err, helpText) {
|
||||
plugins.fireHook('filter:parse.raw', helpText, function(err, helpText) {
|
||||
if (!meta.config['composer:allowPluginHelp'] || meta.config['composer:allowPluginHelp'] === '1') {
|
||||
plugins.fireHook('filter:composer.help', helpText, callback);
|
||||
} else {
|
||||
|
||||
@@ -201,7 +201,7 @@ SocketPosts.edit = function(socket, data, callback) {
|
||||
}
|
||||
|
||||
postTools.edit(socket.uid, data.pid, data.title, data.content, {topic_thumb: data.topic_thumb, tags: data.tags}, function(err, results) {
|
||||
if(err) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
@@ -323,10 +323,9 @@ SocketPosts.flag = function(socket, pid, callback) {
|
||||
},
|
||||
function(topicTitle, next) {
|
||||
message = '[[notifications:user_flagged_post_in, ' + userName + ', ' + topicTitle + ']]';
|
||||
postTools.parse(post.content, next);
|
||||
postTools.parse(post, socket.uid, next);
|
||||
},
|
||||
function(postContent, next) {
|
||||
post.content = postContent;
|
||||
function(post, next) {
|
||||
groups.get('administrators', {}, next);
|
||||
},
|
||||
function(adminGroup, next) {
|
||||
|
||||
@@ -232,7 +232,7 @@ module.exports = function(Topics) {
|
||||
function(next) {
|
||||
async.parallel({
|
||||
userInfo: function(next) {
|
||||
posts.getUserInfoForPosts([postData.uid], next);
|
||||
posts.getUserInfoForPosts([postData.uid], uid, next);
|
||||
},
|
||||
topicInfo: function(next) {
|
||||
Topics.getTopicFields(tid, ['tid', 'title', 'slug', 'cid'], next);
|
||||
@@ -244,14 +244,13 @@ module.exports = function(Topics) {
|
||||
posts.getPidIndex(postData.pid, uid, next);
|
||||
},
|
||||
content: function(next) {
|
||||
postTools.parse(postData.content, next);
|
||||
postTools.parsePost(postData, uid, next);
|
||||
}
|
||||
}, next);
|
||||
},
|
||||
function(results, next) {
|
||||
postData.user = results.userInfo[0];
|
||||
postData.topic = results.topicInfo;
|
||||
postData.content = results.content;
|
||||
|
||||
if (results.settings.followTopicsOnReply) {
|
||||
threadTools.follow(postData.tid, uid);
|
||||
|
||||
@@ -68,7 +68,7 @@ module.exports = function(Topics) {
|
||||
}
|
||||
}
|
||||
|
||||
posts.getUserInfoForPosts(uids, function(err, users) {
|
||||
posts.getUserInfoForPosts(uids, uid, function(err, users) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user