Skip to content

Commit

Permalink
remove all instances of the sendEmailAddressChangedNotification function
Browse files Browse the repository at this point in the history
  • Loading branch information
auumgn committed Jul 24, 2024
1 parent 10d2fb4 commit 08d9bf8
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,35 +228,6 @@ public void sendReactivationEmail(String submittedEmail, String userOrcid) {
mailgunManager.sendEmail(EmailConstants.DO_NOT_REPLY_NOTIFY_ORCID_ORG, submittedEmail, verifyEmailUtils.getSubject("email.subject.reactivation", locale), body, htmlBody);
}

public void sendEmailAddressChangedNotification(String currentUserOrcid, String newEmail, String oldEmail) {
ProfileEntity profile = profileEntityCacheManager.retrieve(currentUserOrcid);
Locale userLocale = getUserLocaleFromProfileEntity(profile);

// build up old template
Map<String, Object> templateParams = new HashMap<String, Object>();

String subject = verifyEmailUtils.getSubject("email.subject.email_removed", userLocale);
String emailFriendlyName = recordNameManager.deriveEmailFriendlyName(currentUserOrcid);
templateParams.put("emailName", emailFriendlyName);
String verificationUrl = verifyEmailUtils.createVerificationUrl(newEmail, orcidUrlManager.getBaseUrl());
templateParams.put("verificationUrl", verificationUrl);
templateParams.put("oldEmail", oldEmail);
templateParams.put("newEmail", newEmail);
templateParams.put("orcid", currentUserOrcid);
templateParams.put("baseUri", orcidUrlManager.getBaseUrl());
templateParams.put("baseUriHttp", orcidUrlManager.getBaseUriHttp());
templateParams.put("subject", subject);

verifyEmailUtils.addMessageParams(templateParams, userLocale);

// Generate body from template
String body = templateManager.processTemplate("email_removed.ftl", templateParams);
// Generate html from template
String html = templateManager.processTemplate("email_removed_html.ftl", templateParams);

mailgunManager.sendEmail(EmailConstants.DO_NOT_REPLY_NOTIFY_ORCID_ORG, oldEmail, subject, body, html);
}

public void sendClaimReminderEmail(String userOrcid, int daysUntilActivation, String email) {
ProfileEntity record = profileEntityCacheManager.retrieve(userOrcid);
String primaryEmail = emailManager.findPrimaryEmail(userOrcid).getEmail();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ public void testChangeEmailAddress() throws Exception {

for (org.orcid.jaxb.model.common_v2.Locale locale : org.orcid.jaxb.model.common_v2.Locale.values()) {
profile.setLocale(locale.name());
recordEmailSender.sendEmailAddressChangedNotification(orcid, "[email protected]", "[email protected]");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -985,8 +985,7 @@ public void testAddEmail_noPrimaryEmailChange() {
when(mockEmailManager.emailExists(eq("[email protected]"))).thenReturn(false);

controller.addEmails(mockRequest, newEmail);

verify(mockRecordEmailSender, Mockito.never()).sendEmailAddressChangedNotification(any(), any(), any());

verify(mockRecordEmailSender, Mockito.times(1)).sendVerificationEmail(eq(USER_ORCID), eq("[email protected]"), eq(false));
}

Expand All @@ -1009,7 +1008,6 @@ public void testAddEmail_primaryEmailChange() {

controller.addEmails(mockRequest, newEmail);

verify(mockRecordEmailSender, Mockito.never()).sendEmailAddressChangedNotification(eq(USER_ORCID), eq("[email protected]"), eq("[email protected]"));
verify(mockRecordEmailSender, Mockito.times(1)).sendVerificationEmail(eq(USER_ORCID), eq("[email protected]"), eq(false));
}

Expand All @@ -1030,7 +1028,6 @@ public void testSetPrimary_nothingChange() {

controller.setPrimary(mockRequest, email);

verify(mockRecordEmailSender, Mockito.never()).sendEmailAddressChangedNotification(any(), any(), any());
verify(mockRecordEmailSender, Mockito.never()).sendVerificationEmail(any(), any(), any());
}

Expand All @@ -1051,7 +1048,6 @@ public void testSetPrimary_primaryEmailChange() {

controller.setPrimary(mockRequest, email);

verify(mockRecordEmailSender, Mockito.never()).sendEmailAddressChangedNotification(eq(USER_ORCID), eq("[email protected]"), eq("[email protected]"));
verify(mockRecordEmailSender, Mockito.never()).sendVerificationEmail(any(), any(), any());
}

Expand All @@ -1075,7 +1071,6 @@ public void testSetPrimary_primaryEmailChangeAndPrimaryIsNotVerified() {

controller.setPrimary(mockRequest, email);

verify(mockRecordEmailSender, Mockito.never()).sendEmailAddressChangedNotification(eq(USER_ORCID), eq("[email protected]"), eq("[email protected]"));
verify(mockRecordEmailSender, Mockito.times(1)).sendVerificationEmail(eq(USER_ORCID), eq("[email protected]"), eq(true));
}

Expand All @@ -1099,7 +1094,6 @@ public void testEditEmail_noPrimaryChange() {

controller.editEmail(mockRequest, email);

verify(mockRecordEmailSender, Mockito.never()).sendEmailAddressChangedNotification(any(), any(), any());
verify(mockRecordEmailSender, Mockito.times(1)).sendVerificationEmail(eq(USER_ORCID), eq("[email protected]"), eq(false));
}

Expand All @@ -1120,7 +1114,6 @@ public void testEditEmail_primaryEmailChange() {
when(mockEmailManager.editEmail(eq(USER_ORCID), eq("[email protected]"), eq("[email protected]"), any())).thenReturn(Map.of("verifyAddress", "[email protected]", "new", "[email protected]", "old", "[email protected]"));
controller.editEmail(mockRequest, email);

verify(mockRecordEmailSender, Mockito.never()).sendEmailAddressChangedNotification(eq(USER_ORCID), eq("[email protected]"), eq("[email protected]"));
verify(mockRecordEmailSender, Mockito.times(1)).sendVerificationEmail(eq(USER_ORCID), eq("[email protected]"), eq(true));
}

Expand Down

0 comments on commit 08d9bf8

Please sign in to comment.