mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-16 02:36:16 +01:00
add new hook filter:unread.categories
This commit is contained in:
@@ -244,6 +244,9 @@ helpers.getWatchedCategories = function (uid, selectedCid, callback) {
|
||||
function (next) {
|
||||
user.getWatchedCategories(uid, next);
|
||||
},
|
||||
function (cids, next) {
|
||||
privileges.categories.filterCids('read', cids, uid, next);
|
||||
},
|
||||
function (cids, next) {
|
||||
getCategoryData(cids, uid, selectedCid, next);
|
||||
},
|
||||
@@ -256,9 +259,6 @@ function getCategoryData(cids, uid, selectedCid, callback) {
|
||||
}
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
privileges.categories.filterCids('read', cids, uid, next);
|
||||
},
|
||||
function (cids, next) {
|
||||
categories.getCategoriesFields(cids, ['cid', 'name', 'slug', 'icon', 'link', 'color', 'bgColor', 'parentCid', 'image', 'imageClass'], next);
|
||||
},
|
||||
function (categoryData, next) {
|
||||
@@ -302,8 +302,9 @@ function getCategoryData(cids, uid, selectedCid, callback) {
|
||||
function recursive(category, categoriesData, level) {
|
||||
category.level = level;
|
||||
categoriesData.push(category);
|
||||
|
||||
category.children.forEach(function (child) {
|
||||
recursive(child, categoriesData, ' ' + level);
|
||||
});
|
||||
if (Array.isArray(category.children)) {
|
||||
category.children.forEach(function (child) {
|
||||
recursive(child, categoriesData, ' ' + level);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,11 @@ unreadController.get = function (req, res, next) {
|
||||
|
||||
async.parallel({
|
||||
watchedCategories: function (next) {
|
||||
helpers.getWatchedCategories(req.uid, cid, next);
|
||||
if (plugins.hasListeners('filter:unread.categories')) {
|
||||
plugins.fireHook('filter:unread.categories', { uid: req.uid, cid: cid }, next);
|
||||
} else {
|
||||
helpers.getWatchedCategories(req.uid, cid, next);
|
||||
}
|
||||
},
|
||||
settings: function (next) {
|
||||
user.getSettings(req.uid, next);
|
||||
|
||||
Reference in New Issue
Block a user