mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-08-31 03:18:03 +02:00
closes #1445
This commit is contained in:
@@ -11,6 +11,7 @@ var fs = require('fs'),
|
||||
user = require('./../user'),
|
||||
posts = require('./../posts'),
|
||||
topics = require('./../topics'),
|
||||
messaging = require('../messaging'),
|
||||
postTools = require('../postTools'),
|
||||
utils = require('./../../public/src/utils'),
|
||||
meta = require('./../meta'),
|
||||
@@ -448,7 +449,7 @@ accountsController.uploadPicture = function (req, res, next) {
|
||||
});
|
||||
}
|
||||
|
||||
if(err) {
|
||||
if (err) {
|
||||
fs.unlink(req.files.userPhoto.path);
|
||||
return res.json({error:err.message});
|
||||
}
|
||||
@@ -487,4 +488,16 @@ accountsController.getNotifications = function(req, res, next) {
|
||||
});
|
||||
};
|
||||
|
||||
accountsController.getChats = function(req, res, next) {
|
||||
messaging.getRecentChats(req.user.uid, 0, -1, function(err, chats) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
res.render('chats', {
|
||||
chats: chats
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = accountsController;
|
||||
|
||||
@@ -121,8 +121,8 @@ var db = require('./database'),
|
||||
});
|
||||
};
|
||||
|
||||
Messaging.getRecentChats = function(uid, callback) {
|
||||
db.getSortedSetRevRange('uid:' + uid + ':chats', 0, 9, function(err, uids) {
|
||||
Messaging.getRecentChats = function(uid, start, end, callback) {
|
||||
db.getSortedSetRevRange('uid:' + uid + ':chats', start, end, function(err, uids) {
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
@@ -101,6 +101,9 @@ function accountRoutes(app, middleware, controllers) {
|
||||
|
||||
app.get('/notifications', middleware.buildHeader, 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('/api/chats', middleware.authenticate, controllers.accounts.getChats);
|
||||
}
|
||||
|
||||
function userRoutes(app, middleware, controllers) {
|
||||
|
||||
@@ -238,7 +238,7 @@ function sendTypingNotification(event, socket, data, callback) {
|
||||
}
|
||||
|
||||
SocketModules.chats.list = function(socket, data, callback) {
|
||||
Messaging.getRecentChats(socket.uid, callback);
|
||||
Messaging.getRecentChats(socket.uid, 0, 9, callback);
|
||||
};
|
||||
|
||||
/* Notifications */
|
||||
|
||||
Reference in New Issue
Block a user