v1.18.x
barisusakli 11 years ago
commit 931d46fe7e

@ -7,7 +7,8 @@ var async = require('async'),
topics = require('../topics'), topics = require('../topics'),
notifications = require('../notifications'), notifications = require('../notifications'),
messaging = require('../messaging'), messaging = require('../messaging'),
utils = require('../../public/src/utils'), plugins = require('../plugins'),
utils = require('./../../public/src/utils'),
meta = require('../meta'), meta = require('../meta'),
SocketUser = {}; SocketUser = {};
@ -163,7 +164,7 @@ SocketUser.changePicture = function(socket, data, callback) {
SocketUser.follow = function(socket, data, callback) { SocketUser.follow = function(socket, data, callback) {
if (socket.uid && data) { if (socket.uid && data) {
user.follow(socket.uid, data.uid, function(err) { toggleFollow('follow', socket.uid, data.uid, function(err) {
if (err) { if (err) {
return callback(err); return callback(err);
} }
@ -191,10 +192,23 @@ SocketUser.follow = function(socket, data, callback) {
SocketUser.unfollow = function(socket, data, callback) { SocketUser.unfollow = function(socket, data, callback) {
if (socket.uid && data) { 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) { SocketUser.getSettings = function(socket, data, callback) {
if (socket.uid) { if (socket.uid) {
if (socket.uid === parseInt(data.uid, 10)) { if (socket.uid === parseInt(data.uid, 10)) {

@ -120,8 +120,7 @@ var winston = require('winston'),
plugins.fireHook('action:topic.lock', { plugins.fireHook('action:topic.lock', {
tid: tid, tid: tid,
isLocked: lock, isLocked: lock,
uid: uid, uid: uid
timestamp: Date.now()
}); });
emitTo('topic_' + tid); emitTo('topic_' + tid);
@ -165,8 +164,7 @@ var winston = require('winston'),
plugins.fireHook('action:topic.pin', { plugins.fireHook('action:topic.pin', {
tid: tid, tid: tid,
isPinned: pin, isPinned: pin,
uid: uid, uid: uid
timestamp: Date.now()
}); });
emitTo('topic_' + tid); emitTo('topic_' + tid);
@ -214,8 +212,7 @@ var winston = require('winston'),
tid: tid, tid: tid,
fromCid: oldCid, fromCid: oldCid,
toCid: cid, toCid: cid,
uid: uid, uid: uid
timestamp: Date.now()
}); });
}); });
}; };

Loading…
Cancel
Save