mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-29 18:16:17 +01:00
fix getRecentChats
This commit is contained in:
@@ -23,6 +23,7 @@ define('forum/chats/recent', function() {
|
|||||||
}
|
}
|
||||||
recentChats.attr('loading', 1);
|
recentChats.attr('loading', 1);
|
||||||
socket.emit('modules.chats.getRecentChats', {
|
socket.emit('modules.chats.getRecentChats', {
|
||||||
|
uid: ajaxify.data.uid,
|
||||||
after: recentChats.attr('data-nextstart')
|
after: recentChats.attr('data-nextstart')
|
||||||
}, function(err, data) {
|
}, function(err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ chatsController.get = function(req, res, callback) {
|
|||||||
}
|
}
|
||||||
var uid;
|
var uid;
|
||||||
var recentChats;
|
var recentChats;
|
||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function(next) {
|
function(next) {
|
||||||
user.getUidByUserslug(req.params.userslug, next);
|
user.getUidByUserslug(req.params.userslug, next);
|
||||||
@@ -32,6 +33,7 @@ chatsController.get = function(req, res, callback) {
|
|||||||
if (!req.params.roomid) {
|
if (!req.params.roomid) {
|
||||||
return res.render('chats', {
|
return res.render('chats', {
|
||||||
rooms: recentChats.rooms,
|
rooms: recentChats.rooms,
|
||||||
|
uid: uid,
|
||||||
userslug: req.params.userslug,
|
userslug: req.params.userslug,
|
||||||
nextStart: recentChats.nextStart,
|
nextStart: recentChats.nextStart,
|
||||||
allowed: true,
|
allowed: true,
|
||||||
@@ -69,6 +71,7 @@ chatsController.get = function(req, res, callback) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
room.rooms = recentChats.rooms;
|
room.rooms = recentChats.rooms;
|
||||||
|
room.uid = uid;
|
||||||
room.userslug = req.params.userslug;
|
room.userslug = req.params.userslug;
|
||||||
room.nextStart = recentChats.nextStart;
|
room.nextStart = recentChats.nextStart;
|
||||||
room.title = room.roomName;
|
room.title = room.roomName;
|
||||||
|
|||||||
@@ -295,10 +295,18 @@ SocketModules.chats.getRecentChats = function(socket, data, callback) {
|
|||||||
if (!data || !utils.isNumber(data.after)) {
|
if (!data || !utils.isNumber(data.after)) {
|
||||||
return callback(new Error('[[error:invalid-data]]'));
|
return callback(new Error('[[error:invalid-data]]'));
|
||||||
}
|
}
|
||||||
var start = parseInt(data.after, 10),
|
var start = parseInt(data.after, 10);
|
||||||
stop = start + 9;
|
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) {
|
SocketModules.chats.hasPrivateChat = function(socket, uid, callback) {
|
||||||
|
|||||||
Reference in New Issue
Block a user