mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
refactor: simpler check in user.blocks.filter
This commit is contained in:
@@ -100,14 +100,7 @@ module.exports = function (User) {
|
|||||||
property = 'uid';
|
property = 'uid';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Array.isArray(set) || !set.length || !set.every((item) => {
|
if (!Array.isArray(set) || !set.length) {
|
||||||
if (!item) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const check = item.hasOwnProperty(property) ? item[property] : item;
|
|
||||||
return ['number', 'string'].includes(typeof check);
|
|
||||||
})) {
|
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,7 +109,7 @@ module.exports = function (User) {
|
|||||||
const blockedSet = new Set(blocked_uids);
|
const blockedSet = new Set(blocked_uids);
|
||||||
|
|
||||||
set = set.filter(function (item) {
|
set = set.filter(function (item) {
|
||||||
return !blockedSet.has(parseInt(isPlain ? item : item[property], 10));
|
return !blockedSet.has(parseInt(isPlain ? item : (item && item[property]), 10));
|
||||||
});
|
});
|
||||||
const data = await plugins.fireHook('filter:user.blocks.filter', { set: set, property: property, uid: uid, blockedSet: blockedSet });
|
const data = await plugins.fireHook('filter:user.blocks.filter', { set: set, property: property, uid: uid, blockedSet: blockedSet });
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user