From 927971b392036da979fcca1bc4e824466ace76a6 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 20 May 2015 17:40:08 -0400 Subject: [PATCH] added hooks for following/follower retrieval --- src/user/follow.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/user/follow.js b/src/user/follow.js index fc776bcef8..34efbf8149 100644 --- a/src/user/follow.js +++ b/src/user/follow.js @@ -2,6 +2,7 @@ 'use strict'; var async = require('async'), + plugins = require('../plugins'), db = require('./../database'); module.exports = function(User) { @@ -54,24 +55,31 @@ module.exports = function(User) { } User.getFollowing = function(uid, start, stop, callback) { - getFollow(uid, 'following:' + uid, start, stop, callback); + getFollow(uid, 'following', start, stop, callback); }; User.getFollowers = function(uid, start, stop, callback) { - getFollow(uid, 'followers:' + uid, start, stop, callback); + getFollow(uid, 'followers', start, stop, callback); }; - function getFollow(uid, set, start, stop, callback) { + function getFollow(uid, type, start, stop, callback) { if (!parseInt(uid, 10)) { return callback(null, []); } - db.getSortedSetRevRange(set, start, stop, function(err, uids) { + db.getSortedSetRevRange(type + ':' + uid, start, stop, function(err, uids) { if (err) { return callback(err); } - User.getUsers(uids, uid, callback); + plugins.fireHook('filter:user.' + type, { + uids: uids, + uid: uid, + start: start, + stop: stop + }, function(err, data) { + User.getUsers(data.uids, uid, callback); + }); }); }