mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 05:55:48 +01:00
issue #1788 - start
This commit is contained in:
@@ -32,7 +32,6 @@
|
|||||||
"header.tags": "Tags",
|
"header.tags": "Tags",
|
||||||
"header.popular": "Popular",
|
"header.popular": "Popular",
|
||||||
"header.users": "Users",
|
"header.users": "Users",
|
||||||
"header.chats": "Chats",
|
|
||||||
"header.notifications": "Notifications",
|
"header.notifications": "Notifications",
|
||||||
"header.search": "Search",
|
"header.search": "Search",
|
||||||
"header.profile": "Profile",
|
"header.profile": "Profile",
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
"chat.user_typing": "%1 is typing ...",
|
"chat.user_typing": "%1 is typing ...",
|
||||||
"chat.user_has_messaged_you": "%1 has messaged you.",
|
"chat.user_has_messaged_you": "%1 has messaged you.",
|
||||||
"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.recent-chats": "Recent Chats",
|
||||||
|
|
||||||
"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,8 +486,11 @@ accountsController.getChats = function(req, res, next) {
|
|||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(res.locals.messages);
|
||||||
|
|
||||||
res.render('chats', {
|
res.render('chats', {
|
||||||
chats: chats
|
chats: chats,
|
||||||
|
messages: res.locals.messages || undefined
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -77,9 +77,10 @@ var db = require('./database'),
|
|||||||
}
|
}
|
||||||
|
|
||||||
async.map(messages, function(message, next) {
|
async.map(messages, function(message, next) {
|
||||||
var self = parseInt(message.fromuid, 10) === parseInt(fromuid)
|
var self = parseInt(message.fromuid, 10) === parseInt(fromuid, 10);
|
||||||
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();
|
||||||
|
|
||||||
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;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ var app,
|
|||||||
db = require('./../database'),
|
db = require('./../database'),
|
||||||
categories = require('./../categories'),
|
categories = require('./../categories'),
|
||||||
topics = require('./../topics'),
|
topics = require('./../topics'),
|
||||||
|
messaging = require('../messaging'),
|
||||||
|
|
||||||
controllers = {
|
controllers = {
|
||||||
api: require('./../controllers/api')
|
api: require('./../controllers/api')
|
||||||
@@ -189,6 +190,20 @@ middleware.checkAccountPermissions = function(req, res, next) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
middleware.getChatMessages = function(req, res, next) {
|
||||||
|
user.getUidByUserslug(req.params.userslug, function(err, toUid) {
|
||||||
|
if (!err && toUid) {
|
||||||
|
messaging.getMessages(req.user.uid, toUid, 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,6 +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('/api/chats/:userslug', middleware.authenticate, middleware.getChatMessages, controllers.accounts.getChats);
|
||||||
}
|
}
|
||||||
|
|
||||||
function userRoutes(app, middleware, controllers) {
|
function userRoutes(app, middleware, controllers) {
|
||||||
|
|||||||
Reference in New Issue
Block a user