fix getRecentChats

v1.18.x
barisusakli 8 years ago
parent 515ed0fc6b
commit 4be20799ec

@ -23,6 +23,7 @@ define('forum/chats/recent', function() {
}
recentChats.attr('loading', 1);
socket.emit('modules.chats.getRecentChats', {
uid: ajaxify.data.uid,
after: recentChats.attr('data-nextstart')
}, function(err, data) {
if (err) {

@ -16,6 +16,7 @@ chatsController.get = function(req, res, callback) {
}
var uid;
var recentChats;
async.waterfall([
function(next) {
user.getUidByUserslug(req.params.userslug, next);
@ -32,6 +33,7 @@ chatsController.get = function(req, res, callback) {
if (!req.params.roomid) {
return res.render('chats', {
rooms: recentChats.rooms,
uid: uid,
userslug: req.params.userslug,
nextStart: recentChats.nextStart,
allowed: true,
@ -69,6 +71,7 @@ chatsController.get = function(req, res, callback) {
});
room.rooms = recentChats.rooms;
room.uid = uid;
room.userslug = req.params.userslug;
room.nextStart = recentChats.nextStart;
room.title = room.roomName;

@ -295,10 +295,18 @@ SocketModules.chats.getRecentChats = function(socket, data, callback) {
if (!data || !utils.isNumber(data.after)) {
return callback(new Error('[[error:invalid-data]]'));
}
var start = parseInt(data.after, 10),
stop = start + 9;
var start = parseInt(data.after, 10);
var stop = start + 9;
if (socket.uid === parseInt(data.uid, 10)) {
return Messaging.getRecentChats(socket.uid, start, stop, callback);
}
Messaging.getRecentChats(socket.uid, start, stop, callback);
user.isAdminOrGlobalMod(socket.uid, function(err, isAdminOrGlobalMod) {
if (err || !isAdminOrGlobalMod) {
return callback(err || new Error('[[error:no-privileges]]'));
}
Messaging.getRecentChats(data.uid, start, stop, callback);
});
};
SocketModules.chats.hasPrivateChat = function(socket, uid, callback) {

Loading…
Cancel
Save