mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 23:15:48 +01:00
WIP
This commit is contained in:
@@ -8,6 +8,8 @@
|
|||||||
"chat.see_all": "See all Chats",
|
"chat.see_all": "See all Chats",
|
||||||
"chat.no-messages": "Please select a recipient to view chat message history",
|
"chat.no-messages": "Please select a recipient to view chat message history",
|
||||||
"chat.recent-chats": "Recent Chats",
|
"chat.recent-chats": "Recent Chats",
|
||||||
|
"chat.contacts": "Contacts",
|
||||||
|
"chat.message-history": "Message History",
|
||||||
|
|
||||||
"composer.user_said_in": "%1 said in %2:\n",
|
"composer.user_said_in": "%1 said in %2:\n",
|
||||||
"composer.user_said": "%1 said:\n",
|
"composer.user_said": "%1 said:\n",
|
||||||
|
|||||||
@@ -486,10 +486,12 @@ accountsController.getChats = function(req, res, next) {
|
|||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(res.locals.messages);
|
console.log(res.locals);
|
||||||
|
|
||||||
res.render('chats', {
|
res.render('chats', {
|
||||||
|
meta: res.locals.chatData,
|
||||||
chats: chats,
|
chats: chats,
|
||||||
|
contacts: res.locals.contacts,
|
||||||
messages: res.locals.messages || undefined
|
messages: res.locals.messages || undefined
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -190,20 +190,43 @@ middleware.checkAccountPermissions = function(req, res, next) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
middleware.getChatMessages = function(req, res, next) {
|
/* Chat related middlewares */
|
||||||
user.getUidByUserslug(req.params.userslug, function(err, toUid) {
|
|
||||||
if (!err && toUid) {
|
middleware.chat = {};
|
||||||
messaging.getMessages(req.user.uid, toUid, false, function(err, messages) {
|
middleware.chat.getMetadata = function(req, res, next) {
|
||||||
res.locals.messages = messages;
|
async.waterfall([
|
||||||
next();
|
async.apply(user.getUidByUserslug, req.params.userslug),
|
||||||
});
|
function(toUid, next) {
|
||||||
} else {
|
user.getUserFields(toUid, ['uid', 'username'], next);
|
||||||
res.locals.messages = [];
|
|
||||||
next();
|
|
||||||
}
|
}
|
||||||
|
], function(err, chatData) {
|
||||||
|
if (!err) {
|
||||||
|
res.locals.chatData = chatData;
|
||||||
|
}
|
||||||
|
|
||||||
|
next();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
middleware.chat.getContactList = function(req, res, next) {
|
||||||
|
user.getFollowing(req.user.uid, function(err, contacts) {
|
||||||
|
res.locals.contacts = contacts;
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
middleware.chat.getMessages = function(req, res, next) {
|
||||||
|
if (res.locals.chatData) {
|
||||||
|
messaging.getMessages(req.user.uid, res.locals.chatData.uid, false, function(err, messages) {
|
||||||
|
res.locals.messages = messages;
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
res.locals.messages = [];
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
middleware.buildHeader = function(req, res, next) {
|
middleware.buildHeader = function(req, res, next) {
|
||||||
res.locals.renderHeader = true;
|
res.locals.renderHeader = true;
|
||||||
async.parallel({
|
async.parallel({
|
||||||
|
|||||||
@@ -121,8 +121,8 @@ function accountRoutes(app, middleware, controllers) {
|
|||||||
|
|
||||||
app.get('/chats', middleware.buildHeader, middleware.authenticate, controllers.accounts.getChats);
|
app.get('/chats', middleware.buildHeader, middleware.authenticate, controllers.accounts.getChats);
|
||||||
app.get('/api/chats', middleware.authenticate, controllers.accounts.getChats);
|
app.get('/api/chats', middleware.authenticate, controllers.accounts.getChats);
|
||||||
app.get('/chats/:userslug', middleware.buildHeader, middleware.authenticate, middleware.getChatMessages, 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.getChatMessages, controllers.accounts.getChats);
|
app.get('/api/chats/:userslug', middleware.authenticate, middleware.chat.getMetadata, middleware.chat.getContactList, middleware.chat.getMessages, controllers.accounts.getChats);
|
||||||
}
|
}
|
||||||
|
|
||||||
function userRoutes(app, middleware, controllers) {
|
function userRoutes(app, middleware, controllers) {
|
||||||
|
|||||||
Reference in New Issue
Block a user