mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
removed icon:bgColor and icon:text from db calls
calculates from username on the fly
This commit is contained in:
@@ -240,7 +240,7 @@ module.exports = function(Groups) {
|
|||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
user.getUsersFields(uids, ['uid', 'username', 'picture', 'userslug', 'icon:bgColor', 'icon:text'], next);
|
user.getUsersFields(uids, ['uid', 'username', 'picture', 'userslug'], next);
|
||||||
});
|
});
|
||||||
}, callback);
|
}, callback);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ var db = require('./database'),
|
|||||||
};
|
};
|
||||||
|
|
||||||
function getMessages(mids, fromuid, touid, isNew, callback) {
|
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) {
|
if(err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
@@ -266,7 +266,7 @@ var db = require('./database'),
|
|||||||
db.isSortedSetMembers('uid:' + uid + ':chats:unread', uids, next);
|
db.isSortedSetMembers('uid:' + uid + ':chats:unread', uids, next);
|
||||||
},
|
},
|
||||||
users: function(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) {
|
teasers: function(next) {
|
||||||
async.map(uids, function(fromuid, next) {
|
async.map(uids, function(fromuid, next) {
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ module.exports = function(app, middleware) {
|
|||||||
},
|
},
|
||||||
user: function(next) {
|
user: function(next) {
|
||||||
if (req.uid) {
|
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 {
|
} else {
|
||||||
next(null, {
|
next(null, {
|
||||||
username: '[[global:guest]]',
|
username: '[[global:guest]]',
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ var async = require('async'),
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (notification.from && !notification.image) {
|
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) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ module.exports = function(Posts) {
|
|||||||
|
|
||||||
async.parallel({
|
async.parallel({
|
||||||
users: function(next) {
|
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) {
|
topicsAndCategories: function(next) {
|
||||||
getTopicAndCategories(topicKeys, next);
|
getTopicAndCategories(topicKeys, next);
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ module.exports = function(Posts) {
|
|||||||
user.getMultipleUserSettings(uids, next);
|
user.getMultipleUserSettings(uids, next);
|
||||||
},
|
},
|
||||||
userData: function(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) {
|
online: function(next) {
|
||||||
require('../socket.io').isUsersOnline(uids, next);
|
require('../socket.io').isUsersOnline(uids, next);
|
||||||
|
|||||||
@@ -280,7 +280,7 @@ Sockets.getUsersInRoom = function (uid, roomName, start, stop, callback) {
|
|||||||
if (!uids.length) {
|
if (!uids.length) {
|
||||||
return callback(null, {users: [], total: 0 , room: roomName});
|
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) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,13 +38,13 @@ module.exports = function(SocketPosts) {
|
|||||||
function (results, next) {
|
function (results, next) {
|
||||||
async.parallel({
|
async.parallel({
|
||||||
upvoters: function(next) {
|
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) {
|
upvoteCount: function(next) {
|
||||||
next(null, results.upvoteUids.length);
|
next(null, results.upvoteUids.length);
|
||||||
},
|
},
|
||||||
downvoters: function(next) {
|
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) {
|
downvoteCount: function(next) {
|
||||||
next(null, results.downvoteUids.length);
|
next(null, results.downvoteUids.length);
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ var async = require('async'),
|
|||||||
|
|
||||||
async.parallel({
|
async.parallel({
|
||||||
users: function(next) {
|
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: function(next) {
|
||||||
categories.getCategoriesFields(cids, ['cid', 'name', 'slug', 'icon', 'bgColor', 'color', 'disabled'], 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;
|
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) {
|
function(usersData, next) {
|
||||||
var users = {};
|
var users = {};
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ var async = require('async'),
|
|||||||
};
|
};
|
||||||
|
|
||||||
User.getUsers = function(uids, uid, callback) {
|
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) {
|
plugins.fireHook('filter:users.addFields', {fields: fields}, function(err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(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() {
|
after(function() {
|
||||||
db.flushdb();
|
db.flushdb();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user