Skip to content

Commit

Permalink
add source name and or id to emails missing both
Browse files Browse the repository at this point in the history
  • Loading branch information
auumgn committed Oct 30, 2024
1 parent 6a39790 commit e07961a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,17 @@ public ModelAndView confirmDeactivateOrcidAccount(HttpServletRequest request, Ht
if (Features.EMAIL_DOMAINS.isActive()) {
emailDomains = profileEmailDomainManagerReadOnly.getEmailDomains(getCurrentUserOrcid());
}
return org.orcid.pojo.ajaxForm.Emails.valueOf(v2Emails, emailDomains);
org.orcid.pojo.ajaxForm.Emails emails = org.orcid.pojo.ajaxForm.Emails.valueOf(v2Emails, emailDomains);
// Old emails are missing the source name and id -- assign the user as the source
for (org.orcid.pojo.ajaxForm.Email email: emails.getEmails()) {
if (email.getSource() == null && email.getSourceName() == null) {
String orcid = getCurrentUserOrcid();
String displayName = getPersonDetails(orcid, true).getDisplayName();
email.setSource(orcid);
email.setSourceName(displayName);
}
}
return emails;
}

@RequestMapping(value = "/emails.json", method = RequestMethod.POST)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,16 @@ PublicRecord getRecord(String orcid) {
if (Features.EMAIL_DOMAINS.isActive()) {
emailDomains = profileEmailDomainManagerReadOnly.getPublicEmailDomains(orcid);
}

publicRecord.setEmails(org.orcid.pojo.ajaxForm.Emails.valueOf(filteredEmails, emailDomains));

org.orcid.pojo.ajaxForm.Emails emails = org.orcid.pojo.ajaxForm.Emails.valueOf(filteredEmails, emailDomains);
// Old emails are missing the source name and id -- assign the user as the source
for (org.orcid.pojo.ajaxForm.Email email: emails.getEmails()) {
if (email.getSource() == null && email.getSourceName() == null) {
email.setSource(orcid);
email.setSourceName(publicRecord.getDisplayName());
}
}
publicRecord.setEmails(emails);

// Fill external identifiers
PersonExternalIdentifiers publicPersonExternalIdentifiers;
Expand Down

0 comments on commit e07961a

Please sign in to comment.