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) {
|
function (next) {
|
||||||
user.getWatchedCategories(uid, next);
|
user.getWatchedCategories(uid, next);
|
||||||
},
|
},
|
||||||
|
function (cids, next) {
|
||||||
|
privileges.categories.filterCids('read', cids, uid, next);
|
||||||
|
},
|
||||||
function (cids, next) {
|
function (cids, next) {
|
||||||
getCategoryData(cids, uid, selectedCid, next);
|
getCategoryData(cids, uid, selectedCid, next);
|
||||||
},
|
},
|
||||||
@@ -256,9 +259,6 @@ function getCategoryData(cids, uid, selectedCid, callback) {
|
|||||||
}
|
}
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function (next) {
|
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);
|
categories.getCategoriesFields(cids, ['cid', 'name', 'slug', 'icon', 'link', 'color', 'bgColor', 'parentCid', 'image', 'imageClass'], next);
|
||||||
},
|
},
|
||||||
function (categoryData, next) {
|
function (categoryData, next) {
|
||||||
@@ -302,8 +302,9 @@ function getCategoryData(cids, uid, selectedCid, callback) {
|
|||||||
function recursive(category, categoriesData, level) {
|
function recursive(category, categoriesData, level) {
|
||||||
category.level = level;
|
category.level = level;
|
||||||
categoriesData.push(category);
|
categoriesData.push(category);
|
||||||
|
if (Array.isArray(category.children)) {
|
||||||
category.children.forEach(function (child) {
|
category.children.forEach(function (child) {
|
||||||
recursive(child, categoriesData, ' ' + level);
|
recursive(child, categoriesData, ' ' + level);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,11 @@ unreadController.get = function (req, res, next) {
|
|||||||
|
|
||||||
async.parallel({
|
async.parallel({
|
||||||
watchedCategories: function (next) {
|
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) {
|
settings: function (next) {
|
||||||
user.getSettings(req.uid, next);
|
user.getSettings(req.uid, next);
|
||||||
|
|||||||
Reference in New Issue
Block a user