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