v1.18.x
Baris Soner Usakli 11 years ago
parent 34fc326a37
commit 4c90d22e43

@ -696,9 +696,15 @@ websockets.init = function(io) {
var msg = utils.strip_tags(data.message); var msg = utils.strip_tags(data.message);
user.getUserField(uid, 'username', function(err, username) { user.getMultipleUserFields([uid, touid], ['username'], function(err, usersData) {
if(err) {
return;
}
var finalMessage = username + ' : ' + msg, var finalMessage = username + ' : ' + msg,
notifText = 'New message from <strong>' + username + '</strong>'; notifText = 'New message from <strong>' + username + '</strong>',
username = usersData[0].username,
toUsername = usersData[1].username;
if (!isUserOnline(touid)) { if (!isUserOnline(touid)) {
notifications.create(notifText, 'javascript:app.openChat(&apos;' + username + '&apos;, ' + uid + ');', 'notification_' + uid + '_' + touid, function(nid) { notifications.create(notifText, 'javascript:app.openChat(&apos;' + username + '&apos;, ' + uid + ');', 'notification_' + uid + '_' + touid, function(nid) {
@ -731,7 +737,7 @@ websockets.init = function(io) {
for (var x = 0; x < numSockets; ++x) { for (var x = 0; x < numSockets; ++x) {
userSockets[uid][x].emit('event:chats.receive', { userSockets[uid][x].emit('event:chats.receive', {
fromuid: touid, fromuid: touid,
username: username, username: toUsername,
message: 'You : ' + msg, message: 'You : ' + msg,
timestamp: Date.now() timestamp: Date.now()
}); });

Loading…
Cancel
Save