Skip to content

Node.js based forum software built for the modern web

satifying my OCD

barisusaklib50b5e4787c9
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)) {