mirror of
https://github.com/google/nomulus.git
synced 2025-07-21 02:06:00 +02:00
Prevent removal of abuse contact phone number when updating registrar contact
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=153000833
This commit is contained in:
parent
f433242125
commit
478c7576c6
2 changed files with 44 additions and 6 deletions
|
@ -35,6 +35,7 @@ import google.registry.config.RegistryConfig.Config;
|
|||
import google.registry.export.sheet.SyncRegistrarsSheetAction;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
import google.registry.model.registrar.RegistrarContact;
|
||||
import google.registry.model.registrar.RegistrarContact.Type;
|
||||
import google.registry.request.Action;
|
||||
import google.registry.request.HttpException.BadRequestException;
|
||||
import google.registry.request.JsonActionRunner;
|
||||
|
@ -268,12 +269,25 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA
|
|||
throw new ContactRequirementException(t);
|
||||
}
|
||||
}
|
||||
// Ensure at least one tech contact has a phone number if one was present before.
|
||||
if (any(oldContactsByType.get(RegistrarContact.Type.TECH), HAS_PHONE)
|
||||
&& !any(newContactsByType.get(RegistrarContact.Type.TECH), HAS_PHONE)) {
|
||||
throw new ContactRequirementException(String.format(
|
||||
"At least one %s contact must have a phone number",
|
||||
RegistrarContact.Type.TECH.getDisplayName()));
|
||||
ensurePhoneNumberNotRemovedForContactTypes(
|
||||
oldContactsByType, newContactsByType, Type.ABUSE, Type.TECH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that for each given registrar type, a phone number is present after update, if there
|
||||
* was one before.
|
||||
*/
|
||||
private static void ensurePhoneNumberNotRemovedForContactTypes(
|
||||
Multimap<RegistrarContact.Type, RegistrarContact> oldContactsByType,
|
||||
Multimap<RegistrarContact.Type, RegistrarContact> newContactsByType,
|
||||
RegistrarContact.Type... types) {
|
||||
for (RegistrarContact.Type type : types) {
|
||||
if (any(oldContactsByType.get(type), HAS_PHONE)
|
||||
&& !any(newContactsByType.get(type), HAS_PHONE)) {
|
||||
throw new ContactRequirementException(
|
||||
String.format(
|
||||
"At least one %s contact must have a phone number", type.getDisplayName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue