Skip to content

Commit

Permalink
Add remove method
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoMag committed Apr 18, 2014
1 parent d91f15a commit 5f33700
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions lib/advanced_structures/SocialGraph.js
Expand Up @@ -123,6 +123,40 @@ SocialGraph.prototype.getFollowers = function (callback) {
return this;
}

/**
* Remove user followers and following.
* @param {Function} callback (optional)
* @return this
* @api public
*/
SocialGraph.prototype.remove = function (callback) {

this.getFollowers(function(err, followers_list) {
if(followers_list === undefined || followers_list == undefined) {
followers_list = [];
}
if(followers_list.length > 0) {
// remove permissions from users set.
followers_list.forEach(function (follower) {
var social_graph = createSocialGraph(follower);
social_graph.unfollow(following_list, function(err, value) {});
});
}
})

this.getFollowing(function(err, following_list) {
if(following_list === undefined || following_list == undefined) {
following_list = [];
}
if(following_list.length > 0) {
this.unfollow(following_list, function(err, value) {});
}
});

// TODO: Need to change this code so followers and following list are removed in the same transaction.
return callback(null, "");
}

/**
* Count how many users the current user follows.
*
Expand Down

0 comments on commit 5f33700

Please sign in to comment.