mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 07:07:35 +01:00
fix anonymizing properties
This commit is contained in:
@@ -35,12 +35,29 @@ function _hashUUID (uuid) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function _anonymizeProperties (properties) {
|
function _anonymizeProperties (properties) {
|
||||||
|
if (Array.isArray(properties)) {
|
||||||
return properties.map(userProp => {
|
return properties.map(userProp => {
|
||||||
if (typeof userProp === 'string' && validator.isEmail(userProp)) {
|
if (typeof userProp === 'string' && validator.isEmail(userProp)) {
|
||||||
return _hashUUID(userProp);
|
return _hashUUID(userProp);
|
||||||
}
|
}
|
||||||
return userProp;
|
return userProp;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
if (typeof properties === 'object' && properties !== null) {
|
||||||
|
const anonymizedProps = {};
|
||||||
|
Object.keys(properties).forEach(key => {
|
||||||
|
const value = properties[key];
|
||||||
|
if (typeof value === 'string' && validator.isEmail(value)) {
|
||||||
|
anonymizedProps[key] = _hashUUID(value);
|
||||||
|
} else if (typeof value === 'object' && value !== null) {
|
||||||
|
anonymizedProps[key] = _anonymizeProperties(value);
|
||||||
|
} else {
|
||||||
|
anonymizedProps[key] = value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return anonymizedProps;
|
||||||
|
}
|
||||||
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _lookUpItemName (itemKey) {
|
function _lookUpItemName (itemKey) {
|
||||||
|
|||||||
Reference in New Issue
Block a user