first pass #1720, updating existing calls to notifications.create, backwards compatibility in case plugins create notifications too.

This commit is contained in:
Julian Lam
2014-06-20 16:54:34 -04:00
parent 454c05c391
commit d257632878
6 changed files with 53 additions and 31 deletions

View File

@@ -186,7 +186,7 @@ SocketModules.chats.send = function(socket, data, callback) {
return callback(err);
}
sendChatNotification(socket.uid, touid, message.fromUser.username);
sendChatNotification(socket.uid, touid, message.fromUser.username, message);
server.getUserSockets(touid).forEach(function(s) {
s.emit('event:chats.receive', {
@@ -204,11 +204,14 @@ SocketModules.chats.send = function(socket, data, callback) {
});
};
function sendChatNotification(fromuid, touid, username) {
function sendChatNotification(fromuid, touid, username, message) {
if (!module.parent.exports.isUserOnline(touid)) {
var notifText = '[[notifications:new_message_from, ' + username + ']]';
notifications.create({
text: notifText,
body: {
short: notifText,
long: message
},
path: 'javascript:app.openChat('' + username + '', ' + fromuid + ');',
uniqueId: 'notification_' + fromuid + '_' + touid,
from: fromuid