From d6127e4c0ca0d168ce64165fe9c481f1a5dfcfc0 Mon Sep 17 00:00:00 2001 From: Rachel Guan Date: Thu, 2 Sep 2021 16:58:58 -0400 Subject: [PATCH] Log registrar and certificate info before sending an email (#1308) * Log registrar and certificate info before sending an email --- ...dExpiringCertificateNotificationEmailAction.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/google/registry/batch/SendExpiringCertificateNotificationEmailAction.java b/core/src/main/java/google/registry/batch/SendExpiringCertificateNotificationEmailAction.java index 4f79f84cc..b5412554b 100644 --- a/core/src/main/java/google/registry/batch/SendExpiringCertificateNotificationEmailAction.java +++ b/core/src/main/java/google/registry/batch/SendExpiringCertificateNotificationEmailAction.java @@ -151,6 +151,12 @@ public class SendExpiringCertificateNotificationEmailAction implements Runnable } try { ImmutableSet recipients = getEmailAddresses(registrar, Type.TECH); + Date expirationDate = certificateChecker.getCertificate(certificate.get()).getNotAfter(); + logger.atInfo().log( + "Registrar %s should receive an email that its %s SSL certificate will expire on %s.", + registrar.getRegistrarName(), + certificateType.getDisplayName(), + expirationDate.toString()); if (recipients.isEmpty()) { logger.atWarning().log( "Registrar %s contains no email addresses to receive notification email.", @@ -165,16 +171,11 @@ public class SendExpiringCertificateNotificationEmailAction implements Runnable getEmailBody( registrar.getRegistrarName(), certificateType, - certificateChecker.getCertificate(certificate.get()).getNotAfter(), + expirationDate, registrar.getClientId())) .setRecipients(recipients) .setCcs(getEmailAddresses(registrar, Type.ADMIN)) .build()); - logger.atInfo().log( - "Sent an email to inform registrar %s that its %s SSL certificate will expire on %s.", - registrar.getRegistrarName(), - certificateType.getDisplayName(), - DATE_FORMATTER.print(lastExpiringCertNotificationSentDate)); /* * A duration time offset is used here to ensure that date comparison between two * successive dates is always greater than 1 day. This date is set as last updated date,