satifying my OCD

fire hook after successful follow/unfollow
v1.18.x
barisusakli 11 years ago
parent 0c17ee15f7
commit b50b5e4787

@ -162,26 +162,29 @@ SocketUser.changePicture = function(socket, data, callback) {
SocketUser.follow = function(socket, data, callback) {
if (socket.uid && data) {
plugins.fireHook('action:user.follow', {
fromUid: socket.uid,
toUid: data.uid
});
user.follow(socket.uid, data.uid, callback);
toggleFollow('follow', socket.uid, data.uid, callback);
}
};
SocketUser.unfollow = function(socket, data, callback) {
if (socket.uid && data) {
plugins.fireHook('action:user.unfollow', {
fromUid: socket.uid,
toUid: data.uid
});
user.unfollow(socket.uid, data.uid, callback);
toggleFollow('unfollow', socket.uid, data.uid, callback);
}
};
function toggleFollow(method, uid, theiruid, callback) {
user[method](uid, theiruid, function(err) {
if (err) {
return callback(err);
}
plugins.fireHook('action:user.' + method, {
fromUid: uid,
toUid: theiruid
});
});
}
SocketUser.getSettings = function(socket, data, callback) {
if (socket.uid) {
if (socket.uid === parseInt(data.uid, 10)) {

Loading…
Cancel
Save