|
|
@ -33,14 +33,18 @@ module.exports = function(User) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
User.getFollowing = function(uid, callback) {
|
|
|
|
User.getFollowing = function(uid, callback) {
|
|
|
|
getFollow('following:' + uid, callback);
|
|
|
|
getFollow(uid, 'following:' + uid, callback);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
User.getFollowers = function(uid, callback) {
|
|
|
|
User.getFollowers = function(uid, callback) {
|
|
|
|
getFollow('followers:' + uid, callback);
|
|
|
|
getFollow(uid, 'followers:' + uid, callback);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
function getFollow(set, callback) {
|
|
|
|
function getFollow(uid, set, callback) {
|
|
|
|
|
|
|
|
if (!parseInt(uid, 10)) {
|
|
|
|
|
|
|
|
return callback(null, []);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
db.getSetMembers(set, function(err, uids) {
|
|
|
|
db.getSetMembers(set, function(err, uids) {
|
|
|
|
if (err) {
|
|
|
|
if (err) {
|
|
|
|
return callback(err);
|
|
|
|
return callback(err);
|
|
|
@ -51,10 +55,16 @@ module.exports = function(User) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
User.getFollowingCount = function(uid, callback) {
|
|
|
|
User.getFollowingCount = function(uid, callback) {
|
|
|
|
|
|
|
|
if (!parseInt(uid, 10)) {
|
|
|
|
|
|
|
|
return callback(null, 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
db.setCount('following:' + uid, callback);
|
|
|
|
db.setCount('following:' + uid, callback);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
User.getFollowerCount = function(uid, callback) {
|
|
|
|
User.getFollowerCount = function(uid, callback) {
|
|
|
|
|
|
|
|
if (!parseInt(uid, 10)) {
|
|
|
|
|
|
|
|
return callback(null, 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
db.setCount('followers:' + uid, callback);
|
|
|
|
db.setCount('followers:' + uid, callback);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -70,6 +80,9 @@ module.exports = function(User) {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
User.isFollowing = function(uid, theirid, callback) {
|
|
|
|
User.isFollowing = function(uid, theirid, callback) {
|
|
|
|
|
|
|
|
if (!parseInt(uid, 10) || !parseInt(theirid, 10)) {
|
|
|
|
|
|
|
|
return callback(null, false);
|
|
|
|
|
|
|
|
}
|
|
|
|
db.isSetMember('following:' + uid, theirid, callback);
|
|
|
|
db.isSetMember('following:' + uid, theirid, callback);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|