changed posts.reply to use the getUserFields method and removed the 2 old methods from user.js

v1.18.x
Baris Soner Usakli 12 years ago
parent 47782df9cb
commit 57354fe582

@ -162,29 +162,28 @@ var RDB = require('./redis.js'),
timeout: 2000
});
user.get_user_postdetails(uid, function(user_details) {
user.get_gravatars_by_uids(uid, '', function(gravatars) {
var timestamp = new Date().getTime();
socket.in('topic_' + tid).emit('event:new_post', {
'posts' : [
{
'pid' : pid,
'content' : marked(content || ''),
'uid' : uid,
'username' : user_details.username[0] || 'anonymous',
'user_rep' : user_details.rep[0] || 0,
'post_rep' : 0,
'gravatar' : gravatars[0],
'timestamp' : timestamp,
'relativeTime': utils.relativeTime(timestamp),
'fav_star_class' :'icon-star-empty'
}
]
});
user.getUserFields(uid, ['username','reputation','picture'], function(data){
var timestamp = new Date().getTime();
socket.in('topic_' + tid).emit('event:new_post', {
'posts' : [
{
'pid' : pid,
'content' : marked(content || ''),
'uid' : uid,
'username' : data.username || 'anonymous',
'user_rep' : data.reputation || 0,
'post_rep' : 0,
'gravatar' : data.picture,
'timestamp' : timestamp,
'relativeTime': utils.relativeTime(timestamp),
'fav_star_class' :'icon-star-empty'
}
]
});
});
});
};

@ -52,20 +52,6 @@ var config = require('../config.js'),
RDB.db.hset(String(uid), field, value);
}
User.get_gravatars_by_uids = function(uids, size, callback) {
var gravatars = [];
for(var i=0, ii=uids.length; i<ii; ++i) {
User.getUserField(uids[i], 'picture', function(picture) {
gravatars.push(picture);
if(gravatars.length >= uids.length)
callback(gravatars);
});
}
};
User.loginViaLocal = function(username, password, next) {
if (!username || !password) {
@ -338,32 +324,6 @@ var config = require('../config.js'),
}
};
User.get_user_postdetails = function(uids, callback) {
var multi_queue = RDB.db.multi();
for(var i=0, ii=uids.length; i<ii; ++i) {
multi_queue = multi_queue.hmget(uids[i], 'username', 'reputation');
}
var usernames = [];
var reputations = [];
multi_queue.exec(function (err, replies) {
replies.forEach(function (reply, index) {
usernames.push(reply[0]);
reputations.push(reply[1]);
});
callback({
'username':usernames,
'rep':reputations
});
});
}
User.get_uid_by_email = function(email, callback) {
RDB.get('email:' + email + ':uid', callback)
};

Loading…
Cancel
Save