diff --git a/public/src/modules/notifications.js b/public/src/modules/notifications.js
index b5b4226c58..c3ec88e9b1 100644
--- a/public/src/modules/notifications.js
+++ b/public/src/modules/notifications.js
@@ -20,12 +20,23 @@ define(function() {
notifList.html('');
if (!err && (data.read.length + data.unread.length) > 0) {
+ var image = '';
for (x = 0; x < numUnread; x++) {
- notifList.append($('
' + utils.relativeTime(data.unread[x].datetime, true) + '' + data.unread[x].text + ''));
+ if (data.unread[x].image) {
+ image = '
';
+ } else {
+ image = '';
+ }
+ notifList.append($('' + image + '' + utils.relativeTime(data.unread[x].datetime, true) + '' + data.unread[x].text + ''));
}
for (x = 0; x < numRead; x++) {
- notifList.append($('' + utils.relativeTime(data.read[x].datetime, true) + '' + data.read[x].text + ''));
+ if (data.read[x].image) {
+ image = '
';
+ } else {
+ image = '';
+ }
+ notifList.append($('' + image + '' + utils.relativeTime(data.read[x].datetime, true) + '' + data.read[x].text + ''));
}
} else {
diff --git a/src/notifications.js b/src/notifications.js
index 1310ff8f35..06d20223dd 100644
--- a/src/notifications.js
+++ b/src/notifications.js
@@ -4,7 +4,8 @@ var async = require('async'),
db = require('./database'),
utils = require('../public/src/utils'),
- events = require('./events');
+ events = require('./events'),
+ User = require('./user');
(function(Notifications) {
"use strict";
@@ -27,10 +28,17 @@ var async = require('async'),
if (exists) {
db.sortedSetRank('uid:' + uid + ':notifications:read', nid, function(err, rank) {
- db.getObjectFields('notifications:' + nid, ['nid', 'text', 'score', 'path', 'datetime', 'uniqueId'], function(err, notification) {
-
+ db.getObjectFields('notifications:' + nid, ['nid', 'from', 'text', 'score', 'path', 'datetime', 'uniqueId'], function(err, notification) {
notification.read = rank !== null ? true:false;
- callback(notification);
+
+ if (notification.from) {
+ User.getUserField(notification.from, 'picture', function(err, picture) {
+ notification.image = picture;
+ callback(notification);
+ });
+ } else {
+ callback(notification);
+ }
});
});
} else {
diff --git a/src/socket.io/modules.js b/src/socket.io/modules.js
index f7e2b57369..a222f51d93 100644
--- a/src/socket.io/modules.js
+++ b/src/socket.io/modules.js
@@ -106,7 +106,8 @@ SocketModules.chats.send = function(socket, data) {
notifications.create({
text: notifText,
path: 'javascript:app.openChat('' + username + '', ' + socket.uid + ');',
- uniqueId: 'notification_' + socket.uid + '_' + touid
+ uniqueId: 'notification_' + socket.uid + '_' + touid,
+ from: socket.uid
}, function(nid) {
notifications.push(nid, [touid], function(success) {
diff --git a/src/socket.io/posts.js b/src/socket.io/posts.js
index 87f94c195f..7ad8c7c088 100644
--- a/src/socket.io/posts.js
+++ b/src/socket.io/posts.js
@@ -263,7 +263,8 @@ SocketPosts.flag = function(socket, pid, callback) {
notifications.create({
text: message,
path: path,
- uniqueId: 'post_flag:' + pid
+ uniqueId: 'post_flag:' + pid,
+ from: socket.uid
}, function(nid) {
notifications.push(nid, adminGroup.members, function() {
next(null);
diff --git a/src/threadTools.js b/src/threadTools.js
index da80168473..047e1e6228 100644
--- a/src/threadTools.js
+++ b/src/threadTools.js
@@ -271,7 +271,8 @@ var winston = require('winston'),
notifications.create({
text: '' + username + ' has posted a reply to: "' + topicData.title + '"',
path: nconf.get('relative_path') + '/topic/' + topicData.slug + '#' + pid,
- uniqueId: 'topic:' + tid
+ uniqueId: 'topic:' + tid,
+ from: exceptUid
}, function(nid) {
next(null, nid);
});
diff --git a/src/user.js b/src/user.js
index d3105325d5..1cfab798d9 100644
--- a/src/user.js
+++ b/src/user.js
@@ -717,7 +717,8 @@ var bcrypt = require('bcryptjs'),
notifications.create({
text: message,
path: nconf.get('relative_path') + '/topic/' + slug + '#' + pid,
- uniqueId: 'topic:' + tid
+ uniqueId: 'topic:' + tid,
+ from: uid
}, function(nid) {
notifications.push(nid, followers);
});
@@ -1029,6 +1030,7 @@ var bcrypt = require('bcryptjs'),
getNotifications('uid:' + uid + ':notifications:read', 0, 9, null, next);
}
}, function(err, notifications) {
+ console.log(notifications);
if(err) {
return calback(err);
}