part 1 of notif refactor

This commit is contained in:
barisusakli
2014-09-08 23:03:37 -04:00
parent 01f983e29c
commit 493d0dea1e
17 changed files with 323 additions and 285 deletions

View File

@@ -181,31 +181,33 @@ SocketUser.changePicture = function(socket, data, callback) {
};
SocketUser.follow = function(socket, data, callback) {
if (socket.uid && data) {
toggleFollow('follow', socket.uid, data.uid, function(err) {
if (!socket.uid || !data) {
return;
}
toggleFollow('follow', socket.uid, data.uid, function(err) {
if (err) {
return callback(err);
}
user.getUserFields(socket.uid, ['username', 'userslug'], function(err, userData) {
if (err) {
return callback(err);
}
user.getUserFields(socket.uid, ['username', 'userslug'], function(err, userData) {
if (err) {
return callback(err);
notifications.create({
bodyShort: '[[notifications:user_started_following_you, ' + userData.username + ']]',
path: nconf.get('relative_path') + '/user/' + userData.userslug,
nid: 'follow:uid:' + socket.uid,
from: socket.uid
}, function(err, notification) {
if (!err && notification) {
notifications.push(notification, [data.uid]);
}
notifications.create({
bodyShort: '[[notifications:user_started_following_you, ' + userData.username + ']]',
path: nconf.get('relative_path') + '/user/' + userData.userslug,
uniqueId: 'follow:uid:' + socket.uid,
from: socket.uid
}, function(err, nid) {
if (!err) {
notifications.push(nid, [data.uid]);
}
callback(err);
});
callback(err);
});
});
}
});
};
SocketUser.unfollow = function(socket, data, callback) {