fix: improper handling of single vs. multiple inputs for hidePrivateData

isekai-main
Julian Lam 3 years ago
parent ecf0e8ce22
commit f38b2a737a

@ -146,8 +146,10 @@ module.exports = function (User) {
}; };
User.hidePrivateData = async function (users, callerUID) { User.hidePrivateData = async function (users, callerUID) {
let single = false;
if (!Array.isArray(users)) { if (!Array.isArray(users)) {
users = [users]; users = [users];
single = true;
} }
const [userSettings, isAdmin, isGlobalModerator] = await Promise.all([ const [userSettings, isAdmin, isGlobalModerator] = await Promise.all([
@ -171,7 +173,7 @@ module.exports = function (User) {
return _userData; return _userData;
})); }));
return users.length === 1 ? users.pop() : users; return single ? users.pop() : users;
}; };
async function modifyUserData(users, requestedFields, fieldsToRemove) { async function modifyUserData(users, requestedFields, fieldsToRemove) {

Loading…
Cancel
Save