mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 20:16:04 +01:00
updated to no longer use user.icons.generate, and removed an unneeded upgrade script! :)
This commit is contained in:
@@ -487,27 +487,6 @@ Upgrade.upgrade = function(callback) {
|
||||
next();
|
||||
}
|
||||
},
|
||||
function(next) {
|
||||
thisSchemaDate = Date.UTC(2015, 8, 27);
|
||||
if (schemaDate < thisSchemaDate) {
|
||||
updatesMade = true;
|
||||
winston.info('[2015/09/27] Generating user icons');
|
||||
|
||||
db.getSortedSetRange('users:joindate', 0, -1, function(err, uids) {
|
||||
async.eachLimit(uids, 20, User.icon.generate, function(err) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
winston.info('[2015/09/27] Generating user icons done');
|
||||
Upgrade.update(thisSchemaDate, next);
|
||||
})
|
||||
})
|
||||
} else {
|
||||
winston.info('[2015/09/27] Generating user icons skipped');
|
||||
next();
|
||||
}
|
||||
},
|
||||
function(next) {
|
||||
thisSchemaDate = Date.UTC(2015, 8, 30);
|
||||
if (schemaDate < thisSchemaDate) {
|
||||
|
||||
@@ -33,7 +33,6 @@ var async = require('async'),
|
||||
require('./user/picture')(User);
|
||||
require('./user/approval')(User);
|
||||
require('./user/invite')(User);
|
||||
require('./user/icon')(User);
|
||||
require('./user/password')(User);
|
||||
|
||||
User.updateLastOnlineTime = function(uid, callback) {
|
||||
|
||||
@@ -126,8 +126,7 @@ module.exports = function(User) {
|
||||
async.apply(User.reset.updateExpiry, userData.uid)
|
||||
], next);
|
||||
});
|
||||
},
|
||||
async.apply(User.icon.generate, userData.uid)
|
||||
}
|
||||
], next);
|
||||
},
|
||||
function(results, next) {
|
||||
|
||||
@@ -113,6 +113,13 @@ module.exports = function(User) {
|
||||
for(var i=0; i<fieldsToRemove.length; ++i) {
|
||||
user[fieldsToRemove[i]] = undefined;
|
||||
}
|
||||
|
||||
// User Icons
|
||||
var backgrounds = ['#AB4642', '#DC9656', '#A1B56C', '#7CAFC2', '#BA8BAF', '#A16946'];
|
||||
user['icon:text'] = (user.username[0] || '').toUpperCase();
|
||||
user['icon:bgColor'] = backgrounds[Array.prototype.reduce.call(user.username, function(cur, next) {
|
||||
return cur + next.charCodeAt();
|
||||
}, 0) % backgrounds.length];
|
||||
});
|
||||
|
||||
plugins.fireHook('filter:users.get', users, callback);
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var async = require('async');
|
||||
|
||||
module.exports = function(User) {
|
||||
User.icon = {};
|
||||
|
||||
User.icon.generate = function(uid, callback) {
|
||||
// For convenience, only backgrounds that work well with white as used
|
||||
var backgrounds = ['#AB4642', '#DC9656', '#A1B56C', '#7CAFC2', '#BA8BAF', '#A16946'],
|
||||
bgColor = backgrounds[Math.floor(Math.random() * backgrounds.length)];
|
||||
|
||||
User.getUserField(uid, 'username', function(err, username) {
|
||||
User.setUserFields(uid, {
|
||||
'icon:text': username.slice(0, 1).toUpperCase(),
|
||||
'icon:bgColor': bgColor
|
||||
}, callback);
|
||||
})
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user