|
|
@ -145,25 +145,33 @@ module.exports = function (User) {
|
|
|
|
return await User.getUsersFields(uids, []);
|
|
|
|
return await User.getUsersFields(uids, []);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
User.hidePrivateData = async function (userData, callerUID) {
|
|
|
|
User.hidePrivateData = async function (users, callerUID) {
|
|
|
|
const _userData = { ...userData };
|
|
|
|
if (!Array.isArray(users)) {
|
|
|
|
|
|
|
|
users = [users];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const isSelf = parseInt(callerUID, 10) === parseInt(_userData.uid, 10);
|
|
|
|
|
|
|
|
const [userSettings, isAdmin, isGlobalModerator] = await Promise.all([
|
|
|
|
const [userSettings, isAdmin, isGlobalModerator] = await Promise.all([
|
|
|
|
User.getSettings(_userData.uid),
|
|
|
|
User.getMultipleUserSettings(users.map(user => user.uid)),
|
|
|
|
User.isAdministrator(callerUID),
|
|
|
|
User.isAdministrator(callerUID),
|
|
|
|
User.isGlobalModerator(callerUID),
|
|
|
|
User.isGlobalModerator(callerUID),
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
const privilegedOrSelf = isAdmin || isGlobalModerator || isSelf;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!privilegedOrSelf && (!userSettings.showemail || meta.config.hideEmail)) {
|
|
|
|
users = await Promise.all(users.map(async (userData, idx) => {
|
|
|
|
_userData.email = '';
|
|
|
|
const _userData = { ...userData };
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!privilegedOrSelf && (!userSettings.showfullname || meta.config.hideFullname)) {
|
|
|
|
const isSelf = parseInt(callerUID, 10) === parseInt(_userData.uid, 10);
|
|
|
|
_userData.fullname = '';
|
|
|
|
const privilegedOrSelf = isAdmin || isGlobalModerator || isSelf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!privilegedOrSelf && (!userSettings[idx].showemail || meta.config.hideEmail)) {
|
|
|
|
|
|
|
|
_userData.email = '';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!privilegedOrSelf && (!userSettings[idx].showfullname || meta.config.hideFullname)) {
|
|
|
|
|
|
|
|
_userData.fullname = '';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return _userData;
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
return _userData;
|
|
|
|
return users.length === 1 ? users.pop() : users;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
async function modifyUserData(users, requestedFields, fieldsToRemove) {
|
|
|
|
async function modifyUserData(users, requestedFields, fieldsToRemove) {
|
|
|
|