fix: #7763, parse about me on all profile pages

v1.18.x
Barış Soner Uşaklı 6 years ago
parent faccb191ec
commit f8d341014a

@ -12,10 +12,12 @@ var plugins = require('../../plugins');
var meta = require('../../meta');
var utils = require('../../utils');
var privileges = require('../../privileges');
const translator = require('../../translator');
var helpers = module.exports;
helpers.getUserDataByUserSlug = function (userslug, callerUID, callback) {
let results;
async.waterfall([
function (next) {
user.getUidByUserslug(userslug, next);
@ -113,11 +115,14 @@ helpers.getUserDataByUserSlug = function (userslug, callerUID, callback) {
},
}, next);
},
function (results, next) {
function (_results, next) {
results = _results;
if (!results.userData) {
return callback(new Error('[[error:invalid-uid]]'));
}
parseAboutMe(results.userData, next);
},
function (next) {
var userData = results.userData;
var userSettings = results.userSettings;
var isAdmin = results.isAdmin;
@ -192,7 +197,6 @@ helpers.getUserDataByUserSlug = function (userslug, callerUID, callback) {
userData.fullname = validator.escape(String(userData.fullname || ''));
userData.location = validator.escape(String(userData.location || ''));
userData.signature = validator.escape(String(userData.signature || ''));
userData.aboutme = validator.escape(String(userData.aboutme || ''));
userData.birthday = validator.escape(String(userData.birthday || ''));
userData.moderationNote = validator.escape(String(userData.moderationNote || ''));
@ -211,6 +215,22 @@ helpers.getUserDataByUserSlug = function (userslug, callerUID, callback) {
], callback);
};
function parseAboutMe(userData, callback) {
if (!userData.aboutme) {
return callback();
}
userData.aboutme = validator.escape(String(userData.aboutme || ''));
async.waterfall([
function (next) {
plugins.fireHook('filter:parse.aboutme', userData.aboutme, next);
},
function (aboutme, next) {
userData.aboutmeParsed = translator.escape(aboutme);
next();
},
], callback);
}
function filterLinks(links, states) {
return links.filter(function (link, index) {
// "public" is the old property, if visibility is defined, discard `public`

@ -12,7 +12,6 @@ var meta = require('../../meta');
var accountHelpers = require('./helpers');
var helpers = require('../helpers');
var messaging = require('../../messaging');
var translator = require('../../translator');
var utils = require('../../utils');
var profileController = module.exports;
@ -61,13 +60,6 @@ profileController.get = function (req, res, callback) {
signature: function (next) {
posts.parseSignature(userData, req.uid, next);
},
aboutme: function (next) {
if (userData.aboutme) {
plugins.fireHook('filter:parse.aboutme', userData.aboutme, next);
} else {
next();
}
},
}, next);
},
function (results, next) {
@ -79,7 +71,6 @@ profileController.get = function (req, res, callback) {
userData.latestPosts = results.latestPosts;
userData.bestPosts = results.bestPosts;
userData.hasPrivateChat = results.hasPrivateChat;
userData.aboutme = translator.escape(results.aboutme);
userData.breadcrumbs = helpers.buildBreadcrumbs([{ text: userData.username }]);
userData.title = userData.username;
userData.allowCoverPicture = !userData.isSelf || !!meta.config['reputation:disabled'] || userData.reputation >= meta.config['min:rep:cover-picture'];

Loading…
Cancel
Save