mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-28 03:50:19 +02:00
closes #14030
This commit is contained in:
@@ -158,7 +158,7 @@ categoriesAPI.getTopics = async (caller, data) => {
|
||||
categoriesAPI.setWatchState = async (caller, { cid, state, uid }) => {
|
||||
let targetUid = caller.uid;
|
||||
let cids = Array.isArray(cid) ? cid : [cid];
|
||||
cids = cids.map(cid => (utils.isNumber(cid) ? parseInt(cid, 10) : cid));
|
||||
cids = cids.map(cid => String(cid));
|
||||
|
||||
if (uid) {
|
||||
targetUid = uid;
|
||||
@@ -170,9 +170,9 @@ categoriesAPI.setWatchState = async (caller, { cid, state, uid }) => {
|
||||
// filter to subcategories of cid
|
||||
let cat;
|
||||
do {
|
||||
cat = categoryData.find(c => !cids.includes(c.cid) && cids.includes(c.parentCid));
|
||||
cat = categoryData.find(c => !cids.includes(String(c.cid)) && cids.includes(String(c.parentCid)));
|
||||
if (cat) {
|
||||
cids.push(cat.cid);
|
||||
cids.push(String(cat.cid));
|
||||
}
|
||||
} while (cat);
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ searchApi.categories = async (caller, data) => {
|
||||
data.states = (data.states || ['watching', 'tracking', 'notwatching', 'ignoring']).map(
|
||||
state => categories.watchStates[state]
|
||||
);
|
||||
data.parentCid = parseInt(data.parentCid || 0, 10);
|
||||
data.parentCid = String(data.parentCid || 0);
|
||||
|
||||
let cids;
|
||||
if (data.search) {
|
||||
@@ -42,15 +42,15 @@ searchApi.categories = async (caller, data) => {
|
||||
});
|
||||
|
||||
if (Array.isArray(data.selectedCids)) {
|
||||
data.selectedCids = data.selectedCids.map(cid => parseInt(cid, 10));
|
||||
data.selectedCids = data.selectedCids.map(cid => String(cid));
|
||||
}
|
||||
|
||||
let categoriesData = categories.buildForSelectCategories(visibleCategories, ['disabledClass'], data.parentCid);
|
||||
categoriesData = categoriesData.slice(0, 1000);
|
||||
|
||||
categoriesData.forEach((category) => {
|
||||
category.selected = data.selectedCids ? data.selectedCids.includes(category.cid) : false;
|
||||
if (matchedCids.includes(category.cid)) {
|
||||
category.selected = data.selectedCids ? data.selectedCids.includes(String(category.cid)) : false;
|
||||
if (matchedCids.includes(String(category.cid))) {
|
||||
category.match = true;
|
||||
}
|
||||
});
|
||||
@@ -72,7 +72,7 @@ async function findMatchedCids(uid, data) {
|
||||
localOnly: data.localOnly,
|
||||
});
|
||||
|
||||
let matchedCids = result.categories.map(c => c.cid);
|
||||
let matchedCids = result.categories.map(c => String(c.cid));
|
||||
// no need to filter if all 3 states are used
|
||||
const filterByWatchState = !Object.values(categories.watchStates)
|
||||
.every(state => data.states.includes(state));
|
||||
@@ -82,8 +82,12 @@ async function findMatchedCids(uid, data) {
|
||||
matchedCids = matchedCids.filter((cid, index) => data.states.includes(states[index]));
|
||||
}
|
||||
|
||||
const rootCids = _.uniq(_.flatten(await Promise.all(matchedCids.map(categories.getParentCids))));
|
||||
const allChildCids = _.uniq(_.flatten(await Promise.all(matchedCids.map(categories.getChildrenCids))));
|
||||
const rootCids = _.uniq(_.flatten(
|
||||
await Promise.all(matchedCids.map(categories.getParentCids))
|
||||
));
|
||||
const allChildCids = _.uniq(_.flatten(
|
||||
await Promise.all(matchedCids.map(categories.getChildrenCids))
|
||||
));
|
||||
|
||||
return {
|
||||
cids: _.uniq(rootCids.concat(allChildCids).concat(matchedCids)),
|
||||
@@ -145,7 +149,7 @@ searchApi.roomUsers = async (caller, { query, roomId }) => {
|
||||
roomUsers.forEach((user, index) => {
|
||||
if (user) {
|
||||
user.isOwner = isOwners[index];
|
||||
user.canKick = isRoomOwner && (parseInt(user.uid, 10) !== parseInt(caller.uid, 10));
|
||||
user.canKick = isRoomOwner && String(user.uid) !== String(caller.uid);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user