Node.js based forum software built for the modern web
moved privilege check out of getRecentReplies
barisusakli26d67257fe24
diff --git a/src/categories/recentreplies.js b/src/categories/recentreplies.jsindex a5dd10bc4e..825cdc601d 100644--- a/src/categories/recentreplies.js+++ b/src/categories/recentreplies.js@@ -9,30 +9,20 @@ var async = require('async'),module.exports = function(Categories) {Categories.getRecentReplies = function(cid, uid, count, callback) {- if(count === 0 || !count) {+ if(!parseInt(count, 10)) {return callback(null, []);}- CategoryTools.privileges(cid, uid, function(err, privileges) {- if(err) {- return callback(err);+ db.getSortedSetRevRange('categories:recent_posts:cid:' + cid, 0, count - 1, function(err, pids) {+ if (err) {+ return callback(err, []);}- if (!privileges.read) {+ if (!pids || !pids.length) {return callback(null, []);}- db.getSortedSetRevRange('categories:recent_posts:cid:' + cid, 0, count - 1, function(err, pids) {- if (err) {- return callback(err, []);- }-- if (!pids || !pids.length) {- return callback(null, []);- }-- posts.getPostSummaryByPids(pids, true, callback);- });+ posts.getPostSummaryByPids(pids, true, callback);});};diff --git a/src/socket.io/categories.js b/src/socket.io/categories.jsindex a67e5e53c1..eab02b41ee 100644--- a/src/socket.io/categories.js+++ b/src/socket.io/categories.js@@ -1,11 +1,24 @@+'use strict';+var categories = require('../categories'),+ categoryTools = require('../categoryTools'),meta = require('./../meta'),user = require('./../user'),SocketCategories = {};-SocketCategories.getRecentReplies = function(socket, tid, callback) {- categories.getRecentReplies(tid, socket.uid, 4, callback);+SocketCategories.getRecentReplies = function(socket, cid, callback) {+ categoryTools.privileges(cid, socket.uid, function(err, privileges) {+ if (err) {+ return callback(err);+ }++ if (privileges && !privileges.read) {+ return callback(null, []);+ }++ categories.getRecentReplies(cid, socket.uid, 4, callback);+ });};SocketCategories.get = function(socket, data, callback) {