mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-14 01:45:47 +01:00
Merge branch 'master' of https://github.com/designcreateplay/NodeBB
This commit is contained in:
@@ -38,7 +38,7 @@ categoriesController.popular = function(req, res, next) {
|
||||
|
||||
categoriesController.unread = function(req, res, next) {
|
||||
var uid = req.user.uid;
|
||||
|
||||
|
||||
topics.getUnreadTopics(uid, 0, 19, function (err, data) {
|
||||
if(err) {
|
||||
return next(err);
|
||||
@@ -50,7 +50,7 @@ categoriesController.unread = function(req, res, next) {
|
||||
|
||||
categoriesController.unreadTotal = function(req, res, next) {
|
||||
var uid = req.user.uid;
|
||||
|
||||
|
||||
topics.getTotalUnread(uid, function (err, data) {
|
||||
if(err) {
|
||||
return next(err);
|
||||
@@ -63,8 +63,7 @@ categoriesController.unreadTotal = function(req, res, next) {
|
||||
categoriesController.get = function(req, res, next) {
|
||||
var cid = req.params.category_id,
|
||||
page = req.query.page || 1,
|
||||
uid = req.user ? req.user.uid : 0,
|
||||
privileges = null;
|
||||
uid = req.user ? req.user.uid : 0;
|
||||
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
@@ -73,15 +72,14 @@ categoriesController.get = function(req, res, next) {
|
||||
if (!categoryPrivileges.read) {
|
||||
next(new Error('not-enough-privileges'));
|
||||
} else {
|
||||
privileges = categoryPrivileges;
|
||||
next();
|
||||
next(null, categoryPrivileges);
|
||||
}
|
||||
} else {
|
||||
next(err);
|
||||
}
|
||||
});
|
||||
},
|
||||
function (next) {
|
||||
function (privileges, next) {
|
||||
user.getSettings(uid, function(err, settings) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
@@ -90,13 +88,14 @@ categoriesController.get = function(req, res, next) {
|
||||
var start = (page - 1) * settings.topicsPerPage,
|
||||
end = start + settings.topicsPerPage - 1;
|
||||
|
||||
categories.getCategoryById(cid, start, end, 0, function (err, categoryData) {
|
||||
categories.getCategoryById(cid, start, end, uid, function (err, categoryData) {
|
||||
if (categoryData) {
|
||||
if (parseInt(categoryData.disabled, 10) === 1) {
|
||||
return next(new Error('Category disabled'), null);
|
||||
}
|
||||
}
|
||||
|
||||
categoryData.privileges = privileges;
|
||||
next(err, categoryData);
|
||||
});
|
||||
});
|
||||
@@ -132,7 +131,7 @@ categoriesController.get = function(req, res, next) {
|
||||
href: nconf.get('url')
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
next(null, categoryData);
|
||||
}
|
||||
], function (err, data) {
|
||||
@@ -154,7 +153,6 @@ categoriesController.get = function(req, res, next) {
|
||||
category_url += '?' + queryString;
|
||||
}
|
||||
|
||||
data.privileges = privileges;
|
||||
data.currentPage = page;
|
||||
|
||||
// Paginator for noscript
|
||||
|
||||
@@ -70,9 +70,12 @@ SocketPosts.reply = function(socket, data, callback) {
|
||||
var socketData = {
|
||||
posts: [postData]
|
||||
};
|
||||
index.server.sockets.in('topic_' + postData.tid).emit('event:new_post', socketData);
|
||||
index.server.sockets.in('recent_posts').emit('event:new_post', socketData);
|
||||
index.server.sockets.in('user/' + postData.uid).emit('event:new_post', socketData);
|
||||
|
||||
var rooms = ['recent_posts', 'home', 'topic_' + postData.tid, 'user/' + postData.uid];
|
||||
rooms.forEach(function(room) {
|
||||
index.server.sockets.in(room).emit('event:new_post', socketData);
|
||||
});
|
||||
|
||||
callback();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -57,8 +57,10 @@ SocketTopics.post = function(socket, data, callback) {
|
||||
}
|
||||
|
||||
if (result) {
|
||||
|
||||
index.server.sockets.in('category_' + data.category_id).emit('event:new_topic', result.topicData);
|
||||
index.server.sockets.in('recent_posts').emit('event:new_topic', result.topicData);
|
||||
index.server.sockets.in('home').emit('event:new_topic', result.topicData);
|
||||
index.server.sockets.in('user/' + socket.uid).emit('event:new_post', {
|
||||
posts: result.postData
|
||||
});
|
||||
|
||||
@@ -687,7 +687,6 @@ var async = require('async'),
|
||||
};
|
||||
|
||||
Topics.getTopicsByTids = function(tids, uid, callback) {
|
||||
|
||||
if (!Array.isArray(tids) || tids.length === 0) {
|
||||
return callback(null, []);
|
||||
}
|
||||
|
||||
@@ -829,7 +829,7 @@ var bcrypt = require('bcryptjs'),
|
||||
};
|
||||
|
||||
User.isModerator = function(uid, cid, callback) {
|
||||
groups.isMemberByGroupName(uid, 'cid:' + cid + ':privileges:mod', callback);
|
||||
groups.isMemberByGroupName(uid, 'cid:' + cid + ':privileges:mods', callback);
|
||||
};
|
||||
|
||||
User.isAdministrator = function(uid, callback) {
|
||||
|
||||
Reference in New Issue
Block a user