mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
feat: add filter:user.getWatchedCategories
This commit is contained in:
@@ -284,7 +284,7 @@ async function getWatchedCids(data) {
|
|||||||
if (!data.categories.includes('watched')) {
|
if (!data.categories.includes('watched')) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
return await user.getCategoriesByStates(data.uid, [categories.watchStates.watching]);
|
return await user.getWatchedCategories(data.uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getChildrenCids(data) {
|
async function getChildrenCids(data) {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ const _ = require('lodash');
|
|||||||
|
|
||||||
const db = require('../database');
|
const db = require('../database');
|
||||||
const categories = require('../categories');
|
const categories = require('../categories');
|
||||||
|
const plugins = require('../plugins');
|
||||||
|
|
||||||
module.exports = function (User) {
|
module.exports = function (User) {
|
||||||
User.setCategoryWatchState = async function (uid, cids, state) {
|
User.setCategoryWatchState = async function (uid, cids, state) {
|
||||||
@@ -36,14 +37,24 @@ module.exports = function (User) {
|
|||||||
if (!(parseInt(uid, 10) > 0)) {
|
if (!(parseInt(uid, 10) > 0)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
return await User.getCategoriesByStates(uid, [categories.watchStates.ignoring]);
|
const cids = await User.getCategoriesByStates(uid, [categories.watchStates.ignoring]);
|
||||||
|
const result = await plugins.hooks.fire('filter:user.getIgnoredCategories', {
|
||||||
|
uid: uid,
|
||||||
|
cids: cids,
|
||||||
|
});
|
||||||
|
return result.cids;
|
||||||
};
|
};
|
||||||
|
|
||||||
User.getWatchedCategories = async function (uid) {
|
User.getWatchedCategories = async function (uid) {
|
||||||
if (!(parseInt(uid, 10) > 0)) {
|
if (!(parseInt(uid, 10) > 0)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
return await User.getCategoriesByStates(uid, [categories.watchStates.watching]);
|
const cids = await User.getCategoriesByStates(uid, [categories.watchStates.watching]);
|
||||||
|
const result = await plugins.hooks.fire('filter:user.getWatchedCategories', {
|
||||||
|
uid: uid,
|
||||||
|
cids: cids,
|
||||||
|
});
|
||||||
|
return result.cids;
|
||||||
};
|
};
|
||||||
|
|
||||||
User.getCategoriesByStates = async function (uid, states) {
|
User.getCategoriesByStates = async function (uid, states) {
|
||||||
|
|||||||
Reference in New Issue
Block a user