From f4bfcc7351aa192056708b4f25fdad2f0f40fd85 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Thu, 29 Oct 2015 16:35:44 -0400 Subject: [PATCH] removed icon:bgColor and icon:text from db calls calculates from username on the fly --- src/groups/membership.js | 2 +- src/messaging.js | 4 ++-- src/middleware/header.js | 2 +- src/notifications.js | 2 +- src/posts/summary.js | 2 +- src/posts/user.js | 2 +- src/socket.io/index.js | 2 +- src/socket.io/posts/favourites.js | 4 ++-- src/topics.js | 2 +- src/topics/teaser.js | 2 +- src/user.js | 2 +- tests/user.js | 17 ----------------- 12 files changed, 13 insertions(+), 30 deletions(-) diff --git a/src/groups/membership.js b/src/groups/membership.js index a5b7b558c0..663b3d7b14 100644 --- a/src/groups/membership.js +++ b/src/groups/membership.js @@ -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); }; diff --git a/src/messaging.js b/src/messaging.js index 04477f061f..0631de61f8 100644 --- a/src/messaging.js +++ b/src/messaging.js @@ -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) { diff --git a/src/middleware/header.js b/src/middleware/header.js index d5baaeedaa..7fa8e268cb 100644 --- a/src/middleware/header.js +++ b/src/middleware/header.js @@ -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]]', diff --git a/src/notifications.js b/src/notifications.js index a3d4e61ef2..2cd372923e 100644 --- a/src/notifications.js +++ b/src/notifications.js @@ -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); } diff --git a/src/posts/summary.js b/src/posts/summary.js index 7fadb0c6d3..eaa1f5b2ef 100644 --- a/src/posts/summary.js +++ b/src/posts/summary.js @@ -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); diff --git a/src/posts/user.js b/src/posts/user.js index 2c13f403a1..6cd4960a6b 100644 --- a/src/posts/user.js +++ b/src/posts/user.js @@ -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); diff --git a/src/socket.io/index.js b/src/socket.io/index.js index 16188cb266..fd3ab9e995 100644 --- a/src/socket.io/index.js +++ b/src/socket.io/index.js @@ -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); } diff --git a/src/socket.io/posts/favourites.js b/src/socket.io/posts/favourites.js index e706192cc3..71aab9100f 100644 --- a/src/socket.io/posts/favourites.js +++ b/src/socket.io/posts/favourites.js @@ -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); diff --git a/src/topics.js b/src/topics.js index b9e0a6a160..02e1d5cbba 100644 --- a/src/topics.js +++ b/src/topics.js @@ -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); diff --git a/src/topics/teaser.js b/src/topics/teaser.js index 116232fb8c..3973e8ebd6 100644 --- a/src/topics/teaser.js +++ b/src/topics/teaser.js @@ -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 = {}; diff --git a/src/user.js b/src/user.js index c3ef41a6eb..49c4e06b54 100644 --- a/src/user.js +++ b/src/user.js @@ -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); diff --git a/tests/user.js b/tests/user.js index 99a677afce..f9423a62aa 100644 --- a/tests/user.js +++ b/tests/user.js @@ -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(); });