Node.js based forum software built for the modern web
generateNotificationPaths
Barış Soner Uşaklıcc92d09498df
diff --git a/src/user/notifications.js b/src/user/notifications.jsindex c3ea4b9c23..fe9ffc80b8 100644--- a/src/user/notifications.js+++ b/src/user/notifications.js@@ -109,34 +109,38 @@ var async = require('async'),return callback(err);}- var pids = notifications.map(function(notification) {- return notification ? notification.pid : null;- });+ UserNotifications.generateNotificationPaths(notifications, uid, callback);+ });+ };- generatePostPaths(pids, uid, function(err, pidToPaths) {- if (err) {- return callback(err);- }+ UserNotifications.generateNotificationPaths = function (notifications, uid, callback) {+ var pids = notifications.map(function(notification) {+ return notification ? notification.pid : null;+ });- notifications = notifications.map(function(notification, index) {- if (!notification) {- return null;- }+ generatePostPaths(pids, uid, function(err, pidToPaths) {+ if (err) {+ 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 = 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.path = pidToPaths[notification.pid] || notification.path || '';- notification.datetimeISO = utils.toISOString(notification.datetime);- return notification;- });+ if (notification.nid.startsWith('chat')) {+ 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);});};