|
|
|
@ -16,7 +16,9 @@ var config = require('../config.js'),
|
|
|
|
|
},
|
|
|
|
|
removeEmail = false;
|
|
|
|
|
|
|
|
|
|
if (!(fields instanceof Array)) fields = ['username', 'email'];
|
|
|
|
|
if (!(fields instanceof Array))
|
|
|
|
|
fields = ['username', 'email', 'joindate'];
|
|
|
|
|
|
|
|
|
|
if (fields.indexOf('picture') !== -1 && fields.indexOf('email') === -1) {
|
|
|
|
|
fields.push('email');
|
|
|
|
|
removeEmail = true;
|
|
|
|
@ -49,6 +51,35 @@ var config = require('../config.js'),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
User.getUserData = function(uid, callback) {
|
|
|
|
|
var fields = ['username', 'email', 'joindate', 'picture'];
|
|
|
|
|
var keys = [];
|
|
|
|
|
|
|
|
|
|
for(var i = 0, numFields = fields.length; i<numFields; i++) {
|
|
|
|
|
keys.push('uid:' + uid + ':' + fields[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RDB.mget(keys, function(data) {
|
|
|
|
|
|
|
|
|
|
var returnData = {
|
|
|
|
|
uid: uid
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
for(var i=0, numData=data.length; i<numData; i++) {
|
|
|
|
|
returnData[fields[i]] = data[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var md5sum = crypto.createHash('md5');
|
|
|
|
|
|
|
|
|
|
md5sum.update(returnData.email.toLowerCase());
|
|
|
|
|
returnData.picture = 'http://www.gravatar.com/avatar/' + md5sum.digest('hex') + '?s=24';
|
|
|
|
|
|
|
|
|
|
callback(returnData);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
User.get_gravatars_by_uids = function(uids, size, callback) {
|
|
|
|
|
var keys = [];
|
|
|
|
@ -244,11 +275,14 @@ var config = require('../config.js'),
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (email) {
|
|
|
|
|
RDB.set('uid:' + uid + ':email', email);
|
|
|
|
|
RDB.set('email:' + email, uid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RDB.set('uid:' + uid + ':joindate', new Date().getTime());
|
|
|
|
|
|
|
|
|
|
RDB.incr('user:count', function(count) {
|
|
|
|
|
io.sockets.emit('user.count', {count: count});
|
|
|
|
|
});
|
|
|
|
|