mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-29 01:56:12 +01:00
closes #2745
generate paths on retrieval instead of notification creation also fix follow notification path
This commit is contained in:
@@ -320,11 +320,13 @@ var db = require('./database'),
|
||||
};
|
||||
|
||||
function sendNotifications(fromuid, touid, messageObj, callback) {
|
||||
if (!websockets.isUserOnline(touid)) {
|
||||
if (websockets.isUserOnline(touid)) {
|
||||
return callback();
|
||||
}
|
||||
|
||||
notifications.create({
|
||||
bodyShort: '[[notifications:new_message_from, ' + messageObj.fromUser.username + ']]',
|
||||
bodyLong: messageObj.content,
|
||||
path: nconf.get('relative_path') + '/chats/' + utils.slugify(messageObj.fromUser.username),
|
||||
nid: 'chat_' + fromuid + '_' + touid,
|
||||
from: fromuid
|
||||
}, function(err, notification) {
|
||||
@@ -347,6 +349,5 @@ var db = require('./database'),
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}(exports));
|
||||
|
||||
@@ -55,11 +55,12 @@ var async = require('async'),
|
||||
}
|
||||
|
||||
if (notification.from && !notification.image) {
|
||||
User.getUserField(notification.from, 'picture', function(err, picture) {
|
||||
User.getUserFields(notification.from, ['username', 'userslug', 'picture'], function(err, userData) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
notification.image = picture;
|
||||
notification.image = userData.picture;
|
||||
notification.user = userData;
|
||||
next(null, notification);
|
||||
});
|
||||
return;
|
||||
|
||||
@@ -294,7 +294,6 @@ SocketUser.follow = function(socket, data, callback) {
|
||||
|
||||
notifications.create({
|
||||
bodyShort: '[[notifications:user_started_following_you, ' + userData.username + ']]',
|
||||
path: nconf.get('relative_path') + '/user/' + userData.userslug,
|
||||
nid: 'follow:' + data.uid + ':uid:' + socket.uid,
|
||||
from: socket.uid
|
||||
}, function(err, notification) {
|
||||
|
||||
@@ -124,6 +124,13 @@ var async = require('async'),
|
||||
}
|
||||
|
||||
notification.path = pidToPaths[notification.pid] || notification.path || '';
|
||||
|
||||
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.datetimeISO = utils.toISOString(notification.datetime);
|
||||
return notification;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user