a couple final tweaks to contact list and such... #1788

v1.18.x
Julian Lam 11 years ago
parent ac9f104b39
commit 13e4e8dad7

@ -486,6 +486,21 @@ accountsController.getChats = function(req, res, next) {
return next(err); return next(err);
} }
// Remove entries if they were already present as a followed contact
if (res.locals.contacts && res.locals.contacts.length) {
var contactUids = res.locals.contacts.map(function(contact) {
return parseInt(contact.uid, 10);
});
chats = chats.filter(function(chatObj) {
if (contactUids.indexOf(parseInt(chatObj.uid, 10)) !== -1) {
return false;
} else {
return true;
}
});
}
res.render('chats', { res.render('chats', {
meta: res.locals.chatData, meta: res.locals.chatData,
chats: chats, chats: chats,

@ -81,6 +81,7 @@ var db = require('./database'),
message.fromUser = self ? userData[0] : userData[1]; message.fromUser = self ? userData[0] : userData[1];
message.toUser = self ? userData[1] : userData[0]; message.toUser = self ? userData[1] : userData[0];
message.timestampISO = new Date(parseInt(message.timestamp, 10)).toISOString(); message.timestampISO = new Date(parseInt(message.timestamp, 10)).toISOString();
message.self = self ? 1 : 0;
Messaging.parse(message.content, message.fromuid, fromuid, userData[1], userData[0], isNew, function(result) { Messaging.parse(message.content, message.fromuid, fromuid, userData[1], userData[0], isNew, function(result) {
message.content = result; message.content = result;

@ -119,8 +119,8 @@ function accountRoutes(app, middleware, controllers) {
app.get('/notifications', middleware.buildHeader, middleware.authenticate, controllers.accounts.getNotifications); app.get('/notifications', middleware.buildHeader, middleware.authenticate, controllers.accounts.getNotifications);
app.get('/api/notifications', middleware.authenticate, controllers.accounts.getNotifications); app.get('/api/notifications', middleware.authenticate, controllers.accounts.getNotifications);
app.get('/chats', middleware.buildHeader, middleware.authenticate, controllers.accounts.getChats); app.get('/chats', middleware.buildHeader, middleware.authenticate, middleware.chat.getContactList, controllers.accounts.getChats);
app.get('/api/chats', middleware.authenticate, controllers.accounts.getChats); app.get('/api/chats', middleware.authenticate, middleware.chat.getContactList, controllers.accounts.getChats);
app.get('/chats/:userslug', middleware.buildHeader, middleware.authenticate, middleware.chat.getMetadata, middleware.chat.getContactList, middleware.chat.getMessages, controllers.accounts.getChats); app.get('/chats/:userslug', middleware.buildHeader, middleware.authenticate, middleware.chat.getMetadata, middleware.chat.getContactList, middleware.chat.getMessages, controllers.accounts.getChats);
app.get('/api/chats/:userslug', middleware.authenticate, middleware.chat.getMetadata, middleware.chat.getContactList, middleware.chat.getMessages, controllers.accounts.getChats); app.get('/api/chats/:userslug', middleware.authenticate, middleware.chat.getMetadata, middleware.chat.getContactList, middleware.chat.getMessages, controllers.accounts.getChats);
} }

Loading…
Cancel
Save