removed showemail setting from user hash, its in user settings now

v1.18.x
Baris Soner Usakli 11 years ago
parent 3be0ad5bce
commit 020a70ecb6

@ -607,32 +607,34 @@ var fs = require('fs'),
}
function getUserDataByUserSlug(userslug, callerUID, callback) {
var userData;
async.waterfall([
function(next) {
user.getUidByUserslug(userslug, next);
},
function(uid, next) {
if (!uid) {
return next(new Error('invalid-user'));
user.getUidByUserslug(userslug, function(err, uid) {
if(err || !uid) {
return callback(err || new Error('invalid-user'));
}
async.parallel({
userData : function(next) {
user.getUserData(uid, next);
},
function(data, next) {
userData = data;
if (!userData) {
return callback(new Error('invalid-user'));
}
userSettings : function(next) {
user.getSettings(uid, next);
},
isAdmin : function(next) {
user.isAdministrator(callerUID, next);
},
followStats: function(next) {
user.getFollowStats(uid, next);
}
], function(err, isAdmin) {
if(err) {
return callback(err);
}, function(err, results) {
if(err || !results.userData) {
return callback(err || new Error('invalid-user'));
}
var userData = results.userData;
var userSettings = results.userSettings;
var isAdmin = results.isAdmin;
userData.joindate = utils.toISOString(userData.joindate);
if(userData.lastonline) {
userData.lastonline = utils.toISOString(userData.lastonline);
@ -647,14 +649,14 @@ var fs = require('fs'),
}
function canSeeEmail() {
return isAdmin || callerUID == userData.uid || (userData.email && (userData.showemail && parseInt(userData.showemail, 10) === 1));
return isAdmin || callerUID == userData.uid || (userData.email && userSettings.showemail);
}
if (!canSeeEmail()) {
userData.email = "";
}
if (callerUID == userData.uid && (!userData.showemail || parseInt(userData.showemail, 10) === 0)) {
if (callerUID == userData.uid && !userSettings.showemail) {
userData.emailClass = "";
} else {
userData.emailClass = "hide";
@ -668,15 +670,13 @@ var fs = require('fs'),
userData.disableSignatures = meta.config.disableSignatures !== undefined && parseInt(meta.config.disableSignatures, 10) === 1;
user.getFollowStats(userData.uid, function (err, followStats) {
if(err) {
return callback(err);
}
userData.followingCount = followStats.followingCount;
userData.followerCount = followStats.followerCount;
userData.followingCount = results.followStats.followingCount;
userData.followerCount = results.followStats.followerCount;
callback(null, userData);
});
});
}
};

@ -104,8 +104,7 @@ var bcrypt = require('bcryptjs'),
'postcount': 0,
'lastposttime': 0,
'banned': 0,
'status': 'online',
'showemail': 0
'status': 'online'
};
db.setObject('user:' + uid, userData, function(err) {
@ -213,7 +212,7 @@ var bcrypt = require('bcryptjs'),
settings = {}
}
settings.showemail = settings.showemail ? parseInt(settings.showemail, 10) !== 0 : parseInt(meta.config.usePagination, 10) !== 0;
settings.showemail = settings.showemail ? parseInt(settings.showemail, 10) !== 0 : false;
settings.usePagination = settings.usePagination ? parseInt(settings.usePagination, 10) !== 0 : parseInt(meta.config.usePagination, 10) !== 0;
settings.topicsPerPage = settings.topicsPerPage ? parseInt(settings.topicsPerPage, 10) : parseInt(meta.config.topicsPerPage, 10) || 20;
settings.postsPerPage = settings.postsPerPage ? parseInt(settings.postsPerPage, 10) : parseInt(meta.config.postsPerPage, 10) || 10;

Loading…
Cancel
Save