diff --git a/src/socket.io/user.js b/src/socket.io/user.js index e0f536e085..6b9766fea0 100644 --- a/src/socket.io/user.js +++ b/src/socket.io/user.js @@ -7,7 +7,8 @@ var async = require('async'), topics = require('../topics'), notifications = require('../notifications'), messaging = require('../messaging'), - utils = require('../../public/src/utils'), + plugins = require('../plugins'), + utils = require('./../../public/src/utils'), meta = require('../meta'), SocketUser = {}; @@ -163,7 +164,7 @@ SocketUser.changePicture = function(socket, data, callback) { SocketUser.follow = function(socket, data, callback) { if (socket.uid && data) { - user.follow(socket.uid, data.uid, function(err) { + toggleFollow('follow', socket.uid, data.uid, function(err) { if (err) { return callback(err); } @@ -191,10 +192,23 @@ SocketUser.follow = function(socket, data, callback) { SocketUser.unfollow = function(socket, data, callback) { if (socket.uid && data) { - 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)) { diff --git a/src/threadTools.js b/src/threadTools.js index 4bff68bdf1..edd478c26a 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 }); }); };