generateNotificationPaths

v1.18.x
Barış Soner Uşaklı 10 years ago
parent 8c0dfa1217
commit cc92d09498

@ -109,34 +109,38 @@ var async = require('async'),
return callback(err); return callback(err);
} }
var pids = notifications.map(function(notification) { UserNotifications.generateNotificationPaths(notifications, uid, callback);
return notification ? notification.pid : null; });
}); };
generatePostPaths(pids, uid, function(err, pidToPaths) { UserNotifications.generateNotificationPaths = function (notifications, uid, callback) {
if (err) { var pids = notifications.map(function(notification) {
return callback(err); return notification ? notification.pid : null;
} });
notifications = notifications.map(function(notification, index) { generatePostPaths(pids, uid, function(err, pidToPaths) {
if (!notification) { if (err) {
return null; return callback(err);
} }
notification.path = pidToPaths[notification.pid] || notification.path || ''; notifications = notifications.map(function(notification, index) {
if (!notification) {
return null;
}
if (notification.nid.startsWith('chat')) { notification.path = pidToPaths[notification.pid] || notification.path || '';
notification.path = nconf.get('relative_path') + '/chats/' + notification.user.userslug;
} else if (notification.nid.startsWith('follow')) {
notification.path = nconf.get('relative_path') + '/user/' + notification.user.userslug;
}
notification.datetimeISO = utils.toISOString(notification.datetime); if (notification.nid.startsWith('chat')) {
return notification; notification.path = nconf.get('relative_path') + '/chats/' + notification.user.userslug;
}); } else if (notification.nid.startsWith('follow')) {
notification.path = nconf.get('relative_path') + '/user/' + notification.user.userslug;
}
callback(null, notifications); notification.datetimeISO = utils.toISOString(notification.datetime);
return notification;
}); });
callback(null, notifications);
}); });
}; };

Loading…
Cancel
Save