removed icon:bgColor and icon:text from db calls

calculates from username on the fly
v1.18.x
barisusakli 9 years ago
parent d8e50f931e
commit f4bfcc7351

@ -240,7 +240,7 @@ module.exports = function(Groups) {
return next(err);
}
user.getUsersFields(uids, ['uid', 'username', 'picture', 'userslug', 'icon:bgColor', 'icon:text'], next);
user.getUsersFields(uids, ['uid', 'username', 'picture', 'userslug'], next);
});
}, callback);
};

@ -148,7 +148,7 @@ var db = require('./database'),
};
function getMessages(mids, fromuid, touid, isNew, callback) {
user.getUsersFields([fromuid, touid], ['uid', 'username', 'userslug', 'picture', 'icon:bgColor', 'icon:text', 'status'], function(err, userData) {
user.getUsersFields([fromuid, touid], ['uid', 'username', 'userslug', 'picture', 'status'], function(err, userData) {
if(err) {
return callback(err);
}
@ -266,7 +266,7 @@ var db = require('./database'),
db.isSortedSetMembers('uid:' + uid + ':chats:unread', uids, next);
},
users: function(next) {
user.getUsersFields(uids, ['uid', 'username', 'picture', 'icon:bgColor', 'icon:text', 'status'] , next);
user.getUsersFields(uids, ['uid', 'username', 'picture', 'status'] , next);
},
teasers: function(next) {
async.map(uids, function(fromuid, next) {

@ -72,7 +72,7 @@ module.exports = function(app, middleware) {
},
user: function(next) {
if (req.uid) {
user.getUserFields(req.uid, ['username', 'userslug', 'email', 'picture', 'icon:bgColor', 'icon:text', 'status', 'email:confirmed', 'banned'], next);
user.getUserFields(req.uid, ['username', 'userslug', 'email', 'picture', 'status', 'email:confirmed', 'banned'], next);
} else {
next(null, {
username: '[[global:guest]]',

@ -52,7 +52,7 @@ var async = require('async'),
}
if (notification.from && !notification.image) {
User.getUserFields(notification.from, ['username', 'userslug', 'picture', 'icon:bgColor', 'icon:text'], function(err, userData) {
User.getUserFields(notification.from, ['username', 'userslug', 'picture'], function(err, userData) {
if (err) {
return next(err);
}

@ -46,7 +46,7 @@ module.exports = function(Posts) {
async.parallel({
users: function(next) {
user.getUsersFields(uids, ['uid', 'username', 'userslug', 'picture', 'icon:bgColor', 'icon:text'], next);
user.getUsersFields(uids, ['uid', 'username', 'userslug', 'picture'], next);
},
topicsAndCategories: function(next) {
getTopicAndCategories(topicKeys, next);

@ -20,7 +20,7 @@ module.exports = function(Posts) {
user.getMultipleUserSettings(uids, next);
},
userData: function(next) {
user.getUsersFields(uids, ['uid', 'username', 'userslug', 'reputation', 'postcount', 'picture', 'signature', 'banned', 'status', 'icon:bgColor', 'icon:text'], next);
user.getUsersFields(uids, ['uid', 'username', 'userslug', 'reputation', 'postcount', 'picture', 'signature', 'banned', 'status'], next);
},
online: function(next) {
require('../socket.io').isUsersOnline(uids, next);

@ -280,7 +280,7 @@ Sockets.getUsersInRoom = function (uid, roomName, start, stop, callback) {
if (!uids.length) {
return callback(null, {users: [], total: 0 , room: roomName});
}
user.getUsersFields(uids, ['uid', 'username', 'userslug', 'picture', 'status', 'icon:bgColor', 'icon:text'], function(err, users) {
user.getUsersFields(uids, ['uid', 'username', 'userslug', 'picture', 'status'], function(err, users) {
if (err) {
return callback(err);
}

@ -38,13 +38,13 @@ module.exports = function(SocketPosts) {
function (results, next) {
async.parallel({
upvoters: function(next) {
user.getUsersFields(results.upvoteUids, ['username', 'userslug', 'picture', 'icon:bgColor', 'icon:text'], next);
user.getUsersFields(results.upvoteUids, ['username', 'userslug', 'picture'], next);
},
upvoteCount: function(next) {
next(null, results.upvoteUids.length);
},
downvoters: function(next) {
user.getUsersFields(results.downvoteUids, ['username', 'userslug', 'picture', 'icon:bgColor', 'icon:text'], next);
user.getUsersFields(results.downvoteUids, ['username', 'userslug', 'picture'], next);
},
downvoteCount: function(next) {
next(null, results.downvoteUids.length);

@ -122,7 +122,7 @@ var async = require('async'),
async.parallel({
users: function(next) {
user.getUsersFields(uids, ['uid', 'username', 'userslug', 'picture', 'icon:bgColor', 'icon:text'], next);
user.getUsersFields(uids, ['uid', 'username', 'userslug', 'picture'], next);
},
categories: function(next) {
categories.getCategoriesFields(cids, ['cid', 'name', 'slug', 'icon', 'bgColor', 'color', 'disabled'], next);

@ -44,7 +44,7 @@ module.exports = function(Topics) {
return array.indexOf(uid) === index;
});
user.getUsersFields(uids, ['uid', 'username', 'userslug', 'picture', 'icon:bgColor', 'icon:text'], next);
user.getUsersFields(uids, ['uid', 'username', 'userslug', 'picture'], next);
},
function(usersData, next) {
var users = {};

@ -91,7 +91,7 @@ var async = require('async'),
};
User.getUsers = function(uids, uid, callback) {
var fields = ['uid', 'username', 'userslug', 'picture', 'icon:bgColor', 'icon:text', 'status', 'banned', 'joindate', 'postcount', 'reputation', 'email:confirmed'];
var fields = ['uid', 'username', 'userslug', 'picture', 'status', 'banned', 'joindate', 'postcount', 'reputation', 'email:confirmed'];
plugins.fireHook('filter:users.addFields', {fields: fields}, function(err, data) {
if (err) {
return callback(err);

@ -282,23 +282,6 @@ describe('User', function() {
});
});
describe('User.icon.generate()', function() {
it('should add icon text and bgColor fields to user hash', function(done) {
var backgrounds = ['#AB4642', '#DC9656', '#A1B56C', '#7CAFC2', '#BA8BAF', '#A16946'];
User.icon.generate(1, function(err) {
assert.ifError(err);
User.getUserFields(1, ['icon:text', 'icon:bgColor'], function(err, fields) {
assert.strictEquals('J', fields[0]);
assert(backgrounds.indexOf(fields[1]) !== -1);
done();
});
});
});
});
after(function() {
db.flushdb();
});

Loading…
Cancel
Save