Flag private contact information on houses and other residential buildings (close #5850)

This commit is contained in:
Quincy Morgan
2019-03-20 17:14:44 -04:00
parent 66580a1e79
commit 790d2e867e
4 changed files with 113 additions and 0 deletions
+7
View File
@@ -1295,6 +1295,11 @@ en:
title: Outdated Tags
message: '{feature} has outdated tags'
tip: "Some tags change over time and should be updated."
private_data:
title: Private Information
contact:
message: '{feature} might be tagged with private contact information'
tip: "Sensitive data like personal phone numbers should not be tagged."
tag_suggests_area:
title: Lines Tagged as Areas
message: '{feature} should be a closed area based on the tag "{tag}"'
@@ -1327,6 +1332,8 @@ en:
remove_generic_name:
title: Remove the name
annotation: Removed a generic name.
remove_private_info:
annotation: Removed private information.
remove_tag:
title: Remove the tag
annotation: Removed tag.
+10
View File
@@ -1592,6 +1592,13 @@
"message": "{feature} has outdated tags",
"tip": "Some tags change over time and should be updated."
},
"private_data": {
"title": "Private Information",
"contact": {
"message": "{feature} might be tagged with private contact information"
},
"tip": "Sensitive data like personal phone numbers should not be tagged."
},
"tag_suggests_area": {
"title": "Lines Tagged as Areas",
"message": "{feature} should be a closed area based on the tag \"{tag}\"",
@@ -1636,6 +1643,9 @@
"title": "Remove the name",
"annotation": "Removed a generic name."
},
"remove_private_info": {
"annotation": "Removed private information."
},
"remove_tag": {
"title": "Remove the tag",
"annotation": "Removed tag."
+1
View File
@@ -8,5 +8,6 @@ export { validationMissingRole } from './missing_role';
export { validationMissingTag } from './missing_tag';
export { validationOldMultipolygon } from './old_multipolygon';
export { validationOutdatedTags } from './outdated_tags';
export { validationPrivateData } from './private_data';
export { validationTagSuggestsArea } from './tag_suggests_area';
export { validationUnknownRoad } from './unknown_road';
+95
View File
@@ -0,0 +1,95 @@
import _clone from 'lodash-es/clone';
import { actionChangeTags } from '../actions';
import { t } from '../util/locale';
import { utilDisplayLabel } from '../util';
import { validationIssue, validationIssueFix } from '../core/validator';
export function validationPrivateData() {
var type = 'private_data';
// assume that some buildings are private
var privateBuildingValues = {
detached: true,
farm: true,
house: true,
residential: true,
semidetached_house: true,
static_caravan: true
};
// but they might be public if they have one of these other tags
var okayModifierKeys = {
amenity: true,
craft: true,
historic: true,
leisure: true,
shop: true,
tourism: true
};
// these tags may contain personally identifying info
var personalTags = {
'contact:email': true,
'contact:fax': true,
'contact:phone': true,
'contact:website': true,
email: true,
fax: true,
phone: true,
website: true
};
function privateDataKeys(entity) {
var tags = entity.tags;
if (!tags.building || !privateBuildingValues[tags.building]) return [];
var privateKeys = [];
for (var key in tags) {
if (okayModifierKeys[key]) return [];
if (personalTags[key]) privateKeys.push(key);
}
return privateKeys;
}
var validation = function(entity, context) {
var privateKeys = privateDataKeys(entity);
if (privateKeys.length === 0) return [];
var fixID = privateKeys.length === 1 ? 'remove_tag' : 'remove_tags';
return [new validationIssue({
type: type,
severity: 'warning',
message: t('issues.private_data.contact.message', {
feature: utilDisplayLabel(entity, context),
}),
tooltip: t('issues.private_data.tip'),
entities: [entity],
info: { privateKeys: privateKeys },
fixes: [
new validationIssueFix({
icon: 'iD-operation-delete',
title: t('issues.fix.' + fixID + '.title'),
onClick: function() {
var entity = this.issue.entities[0];
var tags = _clone(entity.tags);
var privateKeys = this.issue.info.privateKeys;
for (var index in privateKeys) {
delete tags[privateKeys[index]];
}
context.perform(
actionChangeTags(entity.id, tags),
t('issues.fix.remove_private_info.annotation')
);
}
})
]
})];
};
validation.type = type;
return validation;
}