Skip to content

Commit

Permalink
feature: Add encourage user to add works to email events log
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielPalafox committed Dec 13, 2023
1 parent ad5a15f commit 71e9ffa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public enum EmailEventType {
VERIFY_EMAIL_7_DAYS_SENT_SKIPPED, /* we are going to skip notifying email address that where already in the system before launching this */
VERIFY_EMAIL_2_DAYS_SENT,
VERIFY_EMAIL_2_DAYS_SENT_SKIPPED,
VERIFY_EMAIL_TOO_OLD
;
VERIFY_EMAIL_TOO_OLD,
ENCOURAGE_USER_TO_ADD_WORKS_EMAIL_SENT,
ENCOURAGE_USER_TO_ADD_WORKS_EMAIL_SENT_SKIPPED;
}
Original file line number Diff line number Diff line change
Expand Up @@ -597,10 +597,20 @@ private void processUnverifiedEmails(boolean forceSending, int unverifiedDays, E

synchronized public void addWorksToRecord() {
if (Features.SEND_ADD_WORKS_EMAILS.isActive()) {
LOGGER.info("About to process send emails to encourage user to add works");
List<Pair<String, String>> elements = profileDaoReadOnly.findEmailsToSendAddWorksEmail();
List<Pair<String, String>> elements = profileDaoReadOnly.findEmailsToSendAddWorksEmail();
for (Pair<String, String> element: elements) {
sendAddWorksToRecordEmail(element.getLeft(), element.getRight());
String email = element.getLeft();
String userOrcid = element.getRight();
try {
LOGGER.debug("Sending email to encourage user to add works to email address {}, orcid {}", email, userOrcid);
sendAddWorksToRecordEmail(email, userOrcid);
emailEventDao.persist(new EmailEventEntity(email, EmailEventType.ENCOURAGE_USER_TO_ADD_WORKS_EMAIL_SENT));
emailEventDao.flush();
} catch (Exception e) {
LOGGER.error("Unable to send email to encourage user to add works to email: " + email, e);
emailEventDao.persist(new EmailEventEntity(email, EmailEventType.ENCOURAGE_USER_TO_ADD_WORKS_EMAIL_SENT_SKIPPED));
emailEventDao.flush();
}
}
}
}
Expand Down

0 comments on commit 71e9ffa

Please sign in to comment.