notifications.create can return null

This commit is contained in:
barisusakli
2016-01-27 20:03:28 +02:00
parent 19c7411c38
commit add4e6ee5b
6 changed files with 49 additions and 51 deletions

View File

@@ -137,13 +137,13 @@ SocketUser.follow = function(socket, data, callback) {
}
var userData;
async.waterfall([
function(next) {
function (next) {
toggleFollow('follow', socket.uid, data.uid, next);
},
function(next) {
function (next) {
user.getUserFields(socket.uid, ['username', 'userslug'], next);
},
function(_userData, next) {
function (_userData, next) {
userData = _userData;
notifications.create({
bodyShort: '[[notifications:user_started_following_you, ' + userData.username + ']]',
@@ -153,7 +153,10 @@ SocketUser.follow = function(socket, data, callback) {
mergeId: 'notifications:user_started_following_you'
}, next);
},
function(notification, next) {
function (notification, next) {
if (!notification) {
return next();
}
notification.user = userData;
notifications.push(notification, [data.uid], next);
}