From 1036ba463662ca7c7b4f11103b3e47195963530a Mon Sep 17 00:00:00 2001 From: psychobunny Date: Thu, 14 Aug 2014 17:46:58 -0400 Subject: [PATCH 1/3] removing timestamp from thread hooks... completely pointless --- src/threadTools.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/threadTools.js b/src/threadTools.js index 5e52d043c7..601ffc88ae 100644 --- a/src/threadTools.js +++ b/src/threadTools.js @@ -120,8 +120,7 @@ var winston = require('winston'), plugins.fireHook('action:topic.lock', { tid: tid, isLocked: lock, - uid: uid, - timestamp: Date.now() + uid: uid }); emitTo('topic_' + tid); @@ -165,8 +164,7 @@ var winston = require('winston'), plugins.fireHook('action:topic.pin', { tid: tid, isPinned: pin, - uid: uid, - timestamp: Date.now() + uid: uid }); emitTo('topic_' + tid); @@ -214,8 +212,7 @@ var winston = require('winston'), tid: tid, fromCid: oldCid, toCid: cid, - uid: uid, - timestamp: Date.now() + uid: uid }); }); }; From 0c17ee15f74dc548b61903e9f2cd0dbcecf05cd1 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Thu, 14 Aug 2014 17:52:17 -0400 Subject: [PATCH 2/3] action:user.follow and action:user.unfollow --- src/socket.io/user.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/socket.io/user.js b/src/socket.io/user.js index 844c2ac270..04a37313db 100644 --- a/src/socket.io/user.js +++ b/src/socket.io/user.js @@ -5,6 +5,7 @@ var async = require('async'), groups = require('../groups'), topics = require('../topics'), messaging = require('../messaging'), + plugins = require('../plugins'), utils = require('./../../public/src/utils'), meta = require('../meta'), SocketUser = {}; @@ -161,12 +162,22 @@ 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); } }; 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); } }; From b50b5e4787c988fed89b018d10064279311fffe7 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Thu, 14 Aug 2014 17:59:33 -0400 Subject: [PATCH 3/3] satifying my OCD fire hook after successful follow/unfollow --- src/socket.io/user.js | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/socket.io/user.js b/src/socket.io/user.js index 04a37313db..5597a03b3a 100644 --- a/src/socket.io/user.js +++ b/src/socket.io/user.js @@ -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)) {