Node.js based forum software built for the modern web
fix getRecentChats
barisusakli4be20799ecf7
diff --git a/public/src/client/chats/recent.js b/public/src/client/chats/recent.jsindex 6905841269..9afc7ab76a 100644--- a/public/src/client/chats/recent.js+++ b/public/src/client/chats/recent.js@@ -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) {diff --git a/src/controllers/accounts/chats.js b/src/controllers/accounts/chats.jsindex b638cb0006..c6ff2886c1 100644--- a/src/controllers/accounts/chats.js+++ b/src/controllers/accounts/chats.js@@ -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;diff --git a/src/socket.io/modules.js b/src/socket.io/modules.jsindex b77d22252d..900b4de0e6 100644--- a/src/socket.io/modules.js+++ b/src/socket.io/modules.js@@ -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) {