Skip to content

Node.js based forum software built for the modern web

chat teaser

psychobunny71cad7e1819d
diff --git a/src/messaging.js b/src/messaging.js
index e42b6758c9..71887ff365 100644
--- a/src/messaging.js
+++ b/src/messaging.js
@@ -253,6 +253,22 @@ var db = require('./database'),
},
users: function(next) {
user.getMultipleUserFields(uids, ['uid', 'username', 'picture', 'status'] , next);
+ },
+ chatTeasers: function(next) {
+ var teasers = [];
+ async.each(uids, function(fromuid, next) {
+ Messaging.getMessages({
+ fromuid: fromuid,
+ touid: uid,
+ isNew: false,
+ count: 1
+ }, function(err, teaser) {
+ teasers.push(teaser[0]);
+ next(err);
+ });
+ }, function(err) {
+ next(err, teasers);
+ });
}
}, function(err, results) {
if (err) {
@@ -277,6 +293,7 @@ var db = require('./database'),
if (user) {
user.unread = results.unread[index];
user.status = sockets.isUserOnline(user.uid) ? user.status : 'offline';
+ user.chatTeaser = results.chatTeasers[index];
}
});