Readd default email check for email disclose

This commit is contained in:
Erin 2024-01-10 10:38:17 -08:00
parent 683a2f4629
commit 0a13ff9976
No known key found for this signature in database
GPG key ID: 1CAD275313C62460
2 changed files with 14 additions and 12 deletions

View file

@ -29,30 +29,32 @@ class Command(BaseCommand):
logger.info("Updating security emails to public")
# Initializes domains that need to be disclosed
domains = Domain.objects.filter()
statuses=["ready", "dns needed"]
domains = Domain.objects.filter(
state__in=statuses
)
# Call security_contact on all domains to trigger saving contact information
for domain in domains:
contact = domain.security_contact
domains_with_contact = Domain.objects.filter(
security_contact_registry_id__isnull=False
)
logger.info("Found %d domains with security contact.", len(domains_with_contact))
logger.info("Found %d domains with status Ready or DNS Needed.", len(domains))
# Update EPP contact for domains with a security contact
for domain in domains_with_contact:
for domain in domains:
try:
logger.info("Domain %s security contact: %s", domain, domain.security_contact)
domain._update_epp_contact(contact=domain.security_contact)
self.disclosed_domain_contacts.append(copy.deepcopy(domain.security_contact))
logger.info("Domain %s security contact: %s", domain.domain_info, domain.security_contact.email)
if domain.security_contact.email != "registrar@dotgov.gov":
domain._update_epp_contact(contact=domain.security_contact)
self.disclosed_domain_contacts.append(copy.deepcopy(domain.security_contact))
else:
logger.info("Skipping disclose for %s security contact.",
domain.domain_info, domain.security_contact.email)
except Exception as err:
# error condition if domain not in database
self.domains_with_errors.append(copy.deepcopy(domain.domain_info))
logger.error(f"error retrieving domain {domain.domain_info}: {err}")
# Update transition domains to disclose
# Inform user how many contacts were disclosed
logger.info("Updated %d contacts to disclosed.", len(self.disclosed_domain_contacts))

View file

@ -1400,7 +1400,7 @@ class Domain(TimeStampedModel, DomainHelper):
is_security = contact.contact_type == contact.ContactTypeChoices.SECURITY
DF = epp.DiscloseField
fields = {DF.EMAIL}
disclose = is_security
disclose = is_security and contact.email != PublicContact.get_default_security().email
# Delete after testing
logger.info("Updated domain contact to disclose: %s", disclose)
# Will only disclose DF.EMAIL if its not the default