Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
fix: Avoid send PEC when application are not under NAT
Browse files Browse the repository at this point in the history
  • Loading branch information
andrea-putzu committed Apr 19, 2024
1 parent 28169fb commit e116017
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/src/main/resources/config/core-config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ mscore.logoPath = ${PAGOPA_LOGO_URL:resources/logo.png}
mscore.infoCamereEnable = ${INFOCAMERE_ENABLE:false}
mscore.sender-mail = ${MAIL_SENDER_ADDRESS:test@test.it}
mscore.destination-mails = ${DESTINATION_MAILS:}

mscore.enableSendDelegationMail=${SEND_DELEGATION_PEC:false}
mscore.sendEmailToInstitution = ${ONBOARDING_SEND_EMAIL_TO_INSTITUTION:false}
mscore.institutionAlternativeEmail = ${ONBOARDING_INSTITUTION_ALTERNATIVE_EMAIL}
mscore.onboarding-expiring-date = ${ONBOARDING_EXPIRING_DATE:60}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ public class CoreConfig {
private boolean sendEmailToInstitution;
private Integer onboardingExpiringDate;
private boolean infoCamereEnable;
private boolean enableSendDelegationMail;
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ public void sendMailForDelegation(String institutionName, String productId, Stri
userNotificationService.sendDelegationUserNotification(userDestinationMail, mailParametersMapper.getDelegationUserNotificationPath(), product.getTitle(), mailParameters);
log.info("create-delegation-user-email-notification :: Email successful sent");

List<String> institutionDestinationMail = getDestinationMails(partnerInstitution);
log.info(DESTINATION_MAIL_LOG, institutionDestinationMail);
emailConnector.sendMail(mailParametersMapper.getDelegationNotificationPath(), institutionDestinationMail, null, product.getTitle(), mailParameters, null);
log.info("create-delegation-institution-email-notification :: Email successful sent");
if (coreConfig.isEnableSendDelegationMail()) {
List<String> institutionDestinationMail = getDestinationMails(partnerInstitution);
log.info(DESTINATION_MAIL_LOG, institutionDestinationMail);
emailConnector.sendMail(mailParametersMapper.getDelegationNotificationPath(), institutionDestinationMail, null, product.getTitle(), mailParameters, null);
log.info("create-delegation-institution-email-notification :: Email successful sent");
}
} catch (Exception e) {
log.error("create-delegation-email-notification :: Impossible to send email. Error: {}", e.getMessage(), e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ void sendNotificationDelegationMail() {
when(institutionConnector.findById(anyString())).thenReturn(institution);
when(userApiConnector.getUserEmails(institution.getId(), product.getId())).thenReturn(userEmails);
when(coreConfig.isSendEmailToInstitution()).thenReturn(true);
when(coreConfig.isEnableSendDelegationMail()).thenReturn(true);
Assertions.assertDoesNotThrow(() -> notificationService.sendMailForDelegation("institutionName", "productId", "partnerId"));
}

Expand Down

0 comments on commit e116017

Please sign in to comment.