fix getRecentChats

This commit is contained in:
barisusakli
2016-09-20 14:41:53 +03:00
parent 515ed0fc6b
commit 4be20799ec
3 changed files with 15 additions and 3 deletions

View File

@@ -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) {