From f6baf2d47b019713eefde78ca4dc71fb23f2c2c7 Mon Sep 17 00:00:00 2001 From: Manuel Rafeli Date: Mon, 20 May 2024 14:18:50 +0200 Subject: [PATCH] [SELC-4929] refactor: Replace Notification Manager with AWS SDK (#496) --- .../resources/config/core-config.properties | 37 +----- .../selfcare/mscore/api/EmailConnector.java | 2 - .../selfcare/mscore/config/CoreConfig.java | 4 +- .../mscore/config/MailTemplateConfig.java | 31 ----- .../connector/email/EmailConnectorImpl.java | 39 ------ .../email/EmailConnectorImplTest.java | 71 ---------- .../client/NotificationManagerRestClient.java | 26 ---- .../NotificationManagerRestClientConfig.java | 15 --- ...otification-manager-rest-client.properties | 5 - core/pom.xml | 6 + .../core/UserNotificationServiceImpl.java | 59 +++++---- .../mscore/core/config/MsCoreConfig.java | 17 +++ .../core/util/MailParametersMapper.java | 97 -------------- .../core/UserNotificationServiceImplTest.java | 26 +++- .../core/util/MailParametersMapperTest.java | 124 ------------------ .../env/dev-pnpg/terraform.tfvars | 64 +-------- infra/container_apps/env/dev/terraform.tfvars | 68 +--------- .../env/prod-pnpg/terraform.tfvars | 64 +-------- .../container_apps/env/prod/terraform.tfvars | 64 +-------- .../env/uat-pnpg/terraform.tfvars | 66 +--------- infra/container_apps/env/uat/terraform.tfvars | 64 +-------- 21 files changed, 121 insertions(+), 828 deletions(-) delete mode 100644 connector/rest/src/main/java/it/pagopa/selfcare/mscore/connector/rest/client/NotificationManagerRestClient.java delete mode 100644 connector/rest/src/main/java/it/pagopa/selfcare/mscore/connector/rest/config/NotificationManagerRestClientConfig.java delete mode 100644 connector/rest/src/main/resources/config/notification-manager-rest-client.properties diff --git a/app/src/main/resources/config/core-config.properties b/app/src/main/resources/config/core-config.properties index e9d2dd525..fcab7975e 100644 --- a/app/src/main/resources/config/core-config.properties +++ b/app/src/main/resources/config/core-config.properties @@ -7,45 +7,13 @@ 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} -mscore.mail-template.placeholders.onboarding.completePath = ${MAIL_TEMPLATE_COMPLETE_PATH} -mscore.mail-template.placeholders.onboarding.completePathPt = ${MAIL_TEMPLATE_PT_COMPLETE_PATH} -mscore.mail-template.placeholders.onboarding.completePathFd = ${MAIL_TEMPLATE_FD_COMPLETE_NOTIFICATION_PATH} -mscore.mail-template.placeholders.onboarding.completeProductName = productName -mscore.mail-template.placeholders.onboarding.completeSelfcarePlaceholder= ${SELFCARE_URL} -mscore.mail-template.placeholders.onboarding.completeSelfcareName = selfcareURL - -mscore.mail-template.placeholders.onboarding.autocompletePath = ${MAIL_TEMPLATE_AUTOCOMPLETE_PATH:} mscore.mail-template.placeholders.onboarding.delegationNotificationPath = ${MAIL_TEMPLATE_DELEGATION_NOTIFICATION_PATH} mscore.mail-template.placeholders.onboarding.delegationUserNotificationPath = ${MAIL_TEMPLATE_DELEGATION_USER_NOTIFICATION_PATH} mscore.mail-template.placeholders.onboarding.delegationPartnerName = partnerName -mscore.mail-template.placeholders.onboarding.path = ${MAIL_TEMPLATE_PATH} -mscore.mail-template.placeholders.onboarding.userName = requesterName -mscore.mail-template.placeholders.onboarding.userSurname = requesterSurname -mscore.mail-template.placeholders.onboarding.productName = productName mscore.mail-template.placeholders.onboarding.institutionDescription = institutionName - -mscore.mail-template.placeholders.onboarding.confirmTokenName= confirmTokenURL -mscore.mail-template.placeholders.onboarding.confirmTokenPlaceholder = ${MAIL_ONBOARDING_CONFIRMATION_LINK} -mscore.mail-template.placeholders.onboarding.rejectTokenName = rejectTokenURL -mscore.mail-template.placeholders.onboarding.rejectTokenPlaceholder = ${MAIL_ONBOARDING_REJECTION_LINK} -mscore.mail-template.placeholders.onboarding.adminLink = ${SELFCARE_ADMIN_NOTIFICATION_URL} - -mscore.mail-template.placeholders.onboarding.notificationPath = ${MAIL_TEMPLATE_NOTIFICATION_PATH} -mscore.mail-template.placeholders.onboarding.registrationRequestPath = ${MAIL_TEMPLATE_REGISTRATION_REQUEST_PT_PATH} -mscore.mail-template.placeholders.onboarding.registrationNotificationAdminPath = ${MAIL_TEMPLATE_REGISTRATION_NOTIFICATION_ADMIN_PATH} -mscore.mail-template.placeholders.onboarding.notificationAdminEmail = ${ADDRESS_EMAIL_NOTIFICATION_ADMIN} mscore.mail-template.placeholders.onboarding.notificationProductName = productName -mscore.mail-template.placeholders.onboarding.notificationRequesterName = requesterName -mscore.mail-template.placeholders.onboarding.notificationRequesterSurname = requesterSurname - -mscore.mail-template.placeholders.onboarding.rejectPath = ${MAIL_TEMPLATE_REJECT_PATH} -mscore.mail-template.placeholders.onboarding.rejectProductName=productName -mscore.mail-template.placeholders.onboarding.rejectOnboardingUrlPlaceholder=onboardingUrl -mscore.mail-template.placeholders.onboarding.rejectOnboardingUrlValue=${MAIL_ONBOARDING_URL} - scheduler.threads.max-number=${THREADS_SCHEDULE_MAX_NUMBER:1} scheduler.fixed-delay.delay=${SCHEDULER_FIXED_DELAY:20000} @@ -55,3 +23,8 @@ scheduler.regenerate-kafka-queue.enabled=${SCHEDULER_REGENERATE_KAFKA_QUEUE_ENAB mscore.blob-storage.container-product=${PRODUCT_STORAGE_CONTAINER:selc-d-product} mscore.blob-storage.filepath-product = products.json mscore.blob-storage.connection-string-product = ${BLOB_STORAGE_PRODUCT_CONNECTION_STRING:UseDevelopmentStorage=true;} + +#SES +mscore.aws-ses-secret-id=${AWS_SES_ACCESS_KEY_ID:secret-id-example} +mscore.aws-ses-secret-key=${AWS_SES_SECRET_ACCESS_KEY:secret-key-example} +mscore.aws-ses-region=${AWS_SES_REGION:eu-south-1} \ No newline at end of file diff --git a/connector-api/src/main/java/it/pagopa/selfcare/mscore/api/EmailConnector.java b/connector-api/src/main/java/it/pagopa/selfcare/mscore/api/EmailConnector.java index d0059b3ed..9c9733f30 100644 --- a/connector-api/src/main/java/it/pagopa/selfcare/mscore/api/EmailConnector.java +++ b/connector-api/src/main/java/it/pagopa/selfcare/mscore/api/EmailConnector.java @@ -8,6 +8,4 @@ public interface EmailConnector { void sendMail(String templateName, List destinationMail, File pdf, String productName, Map mailParameters, String nameFile); - void sendMailPNPG(String templateName, String destinationMail, String businessName); - } diff --git a/connector-api/src/main/java/it/pagopa/selfcare/mscore/config/CoreConfig.java b/connector-api/src/main/java/it/pagopa/selfcare/mscore/config/CoreConfig.java index 1410c5bc6..0741d36b9 100644 --- a/connector-api/src/main/java/it/pagopa/selfcare/mscore/config/CoreConfig.java +++ b/connector-api/src/main/java/it/pagopa/selfcare/mscore/config/CoreConfig.java @@ -20,10 +20,12 @@ public class CoreConfig { private List destinationMails; private String institutionAlternativeEmail; private boolean sendEmailToInstitution; - private Integer onboardingExpiringDate; private boolean infoCamereEnable; private boolean enableSendDelegationMail; private BlobStorage blobStorage; + private String awsSesSecretId; + private String awsSesSecretKey; + private String awsSesRegion; @Data public static class BlobStorage { diff --git a/connector-api/src/main/java/it/pagopa/selfcare/mscore/config/MailTemplateConfig.java b/connector-api/src/main/java/it/pagopa/selfcare/mscore/config/MailTemplateConfig.java index 1972870d9..dc111e9d0 100644 --- a/connector-api/src/main/java/it/pagopa/selfcare/mscore/config/MailTemplateConfig.java +++ b/connector-api/src/main/java/it/pagopa/selfcare/mscore/config/MailTemplateConfig.java @@ -13,42 +13,11 @@ @ToString public class MailTemplateConfig { - private String completePath; - private String completeProductName; - private String completeSelfcarePlaceholder; - private String completeSelfcareName; - private String completePathFd; - private String completePathPt; - - private String autocompletePath; - private String delegationNotificationPath; private String delegationUserNotificationPath; private String delegationPartnerName; - private String path; - private String userName; - private String userSurname; - private String productName; private String institutionDescription; - private String confirmTokenName; - private String confirmTokenPlaceholder; - private String rejectTokenName; - private String rejectTokenPlaceholder; - private String adminLink; - - private String notificationPath; - private String notificationAdminEmail; private String notificationProductName; - private String notificationRequesterName; - private String notificationRequesterSurname; - - private String rejectPath; - private String rejectProductName; - private String rejectOnboardingUrlPlaceholder; - private String rejectOnboardingUrlValue; - - private String registrationRequestPath; - private String registrationNotificationAdminPath; } diff --git a/connector/email/src/main/java/it/pagopa/selfcare/mscore/connector/email/EmailConnectorImpl.java b/connector/email/src/main/java/it/pagopa/selfcare/mscore/connector/email/EmailConnectorImpl.java index 56122b5a3..947c749ab 100644 --- a/connector/email/src/main/java/it/pagopa/selfcare/mscore/connector/email/EmailConnectorImpl.java +++ b/connector/email/src/main/java/it/pagopa/selfcare/mscore/connector/email/EmailConnectorImpl.java @@ -21,16 +21,13 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; -import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Objects; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; import static it.pagopa.selfcare.mscore.constant.GenericError.ERROR_DURING_COMPRESS_FILE; import static it.pagopa.selfcare.mscore.constant.GenericError.ERROR_DURING_SEND_MAIL; -import static it.pagopa.selfcare.mscore.constant.ProductId.PROD_PN; @Slf4j @Service @@ -83,42 +80,6 @@ public void sendMail(String templateName, List destinationMail, File pdf log.trace("sendMessage end"); } - @Override - public void sendMailPNPG(String templateName, String destinationMail, String businessName) { - log.trace("sendMailPNPG start"); - log.debug("sendMailPNPG templateName = {}, destinationMail = {}, businessName = {}", templateName, destinationMail, businessName); - try { - log.info("START - sendMail to {}, for product {}", destinationMail, PROD_PN); - String template = fileStorageConnector.getTemplateFile(templateName); - MailTemplate mailTemplate = mapper.readValue(template, MailTemplate.class); - Map mailParameters = new HashMap<>(); - mailParameters.put("businessName", businessName); - String html = StringSubstitutor.replace(mailTemplate.getBody(), mailParameters); - log.trace("sendMessage start"); - MimeMessage mimeMessage = mailSender.createMimeMessage(); - - MimeMessageHelper message = new MimeMessageHelper(mimeMessage, true, "UTF-8"); - - List destinationMails = Objects.nonNull(coreConfig.getDestinationMails()) && !coreConfig.getDestinationMails().isEmpty() - ? coreConfig.getDestinationMails() - : List.of(destinationMail); - - log.debug("sendMailPNPG destinationMails = {}", destinationMails); - - message.setSubject(mailTemplate.getSubject()); - message.setFrom(coreConfig.getSenderMail()); - message.setTo(destinationMails.toArray(new String[0])); - message.setText(html, true); - - mailSender.send(mimeMessage); - log.info("END - sendMail to {}, for product {}", destinationMail, PROD_PN); - } catch (Exception e) { - log.error(ERROR_DURING_SEND_MAIL.getMessage() + ":", e.getMessage(), e); - throw new MsCoreException(ERROR_DURING_SEND_MAIL.getMessage(), ERROR_DURING_SEND_MAIL.getCode()); - } - log.trace("sendMailPNPG end"); - } - public byte[] zipBytes(String filename, File pdf) { try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); ZipOutputStream zos = new ZipOutputStream(baos)) { diff --git a/connector/email/src/test/java/it/pagopa/selfcare/mscore/connector/email/EmailConnectorImplTest.java b/connector/email/src/test/java/it/pagopa/selfcare/mscore/connector/email/EmailConnectorImplTest.java index 734446fa1..6cb7d390f 100644 --- a/connector/email/src/test/java/it/pagopa/selfcare/mscore/connector/email/EmailConnectorImplTest.java +++ b/connector/email/src/test/java/it/pagopa/selfcare/mscore/connector/email/EmailConnectorImplTest.java @@ -97,76 +97,5 @@ void testSendMail2() { verify(fileStorageConnector).getTemplateFile(any()); } - @Test - void testSendMailPNPG() throws IOException { - final String senderMail = "senderMail"; - ArrayList destinationMails = new ArrayList<>(); - final String destinationMail = "destinationMail"; - final String templateName = "templateName"; - final String templateFile = "templateFile"; - final String businessName = "businessName"; - - when(fileStorageConnector.getTemplateFile(any())).thenReturn(templateFile); - MailTemplate mailTemplate = new MailTemplate(); - mailTemplate.setBody("body"); - mailTemplate.setSubject("subject"); - when(mapper.readValue(anyString(), eq(MailTemplate.class))).thenReturn(mailTemplate); - - MimeMessage mimeMessage = mock(MimeMessage.class); - when(javaMailSender.createMimeMessage()).thenReturn(mimeMessage); - when(coreConfig.getSenderMail()).thenReturn(senderMail); - when(coreConfig.getDestinationMails()).thenReturn(destinationMails); - - Assertions.assertDoesNotThrow(() -> emailConnector.sendMailPNPG(templateName, destinationMail, businessName)); - } - - @Test - void testSendMailPNPG_changeDestinationMail() throws IOException { - final String senderMail = "senderMail"; - final String destinationMail = "destinationMail"; - ArrayList destinationMails = new ArrayList<>(); - destinationMails.add(destinationMail); - final String templateName = "templateName"; - final String templateFile = "templateFile"; - final String businessName = "businessName"; - - when(fileStorageConnector.getTemplateFile(any())).thenReturn(templateFile); - MailTemplate mailTemplate = new MailTemplate(); - mailTemplate.setBody("body"); - mailTemplate.setSubject("subject"); - when(mapper.readValue(anyString(), eq(MailTemplate.class))).thenReturn(mailTemplate); - - MimeMessage mimeMessage = mock(MimeMessage.class); - when(javaMailSender.createMimeMessage()).thenReturn(mimeMessage); - when(coreConfig.getSenderMail()).thenReturn(senderMail); - when(coreConfig.getDestinationMails()).thenReturn(destinationMails); - - Assertions.assertDoesNotThrow(() -> emailConnector.sendMailPNPG(templateName, destinationMail, businessName)); - } - - @Test - void testSendMailPGNG_exception() throws JsonProcessingException { - final String senderMail = "senderMail"; - final String destinationMail = "destinationMail"; - final String templateName = "templateName"; - final String templateFile = "templateFile"; - final String businessName = "businessName"; - - when(fileStorageConnector.getTemplateFile(any())).thenReturn(templateFile); - MailTemplate mailTemplate = new MailTemplate(); - mailTemplate.setBody("body"); - mailTemplate.setSubject("subject"); - when(mapper.readValue(anyString(), eq(MailTemplate.class))).thenReturn(mailTemplate); - - MimeMessage mimeMessage = mock(MimeMessage.class); - when(javaMailSender.createMimeMessage()).thenReturn(mimeMessage); - when(coreConfig.getSenderMail()).thenReturn(senderMail); - when(coreConfig.getDestinationMails()).thenReturn(null); - - doThrow(RuntimeException.class).when(javaMailSender).send(any(MimeMessage.class)); - Assertions.assertThrows(MsCoreException.class, () -> emailConnector.sendMailPNPG(templateName,destinationMail,businessName)); - - } - } diff --git a/connector/rest/src/main/java/it/pagopa/selfcare/mscore/connector/rest/client/NotificationManagerRestClient.java b/connector/rest/src/main/java/it/pagopa/selfcare/mscore/connector/rest/client/NotificationManagerRestClient.java deleted file mode 100644 index 32a6d1a84..000000000 --- a/connector/rest/src/main/java/it/pagopa/selfcare/mscore/connector/rest/client/NotificationManagerRestClient.java +++ /dev/null @@ -1,26 +0,0 @@ -package it.pagopa.selfcare.mscore.connector.rest.client; - -import it.pagopa.selfcare.mscore.api.NotificationServiceConnector; -import it.pagopa.selfcare.mscore.model.notification.MessageRequest; -import it.pagopa.selfcare.mscore.model.notification.MultipleReceiverMessageRequest; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.ResponseBody; - -/** - * Notification Manager Rest Client - */ -@FeignClient(name = "${rest-client.notification-manager.serviceCode}", url = "${rest-client.notification-manager.base-url}") -public interface NotificationManagerRestClient extends NotificationServiceConnector { - - @PostMapping(value = "${rest-client.notification-manager.sendNotificationToUser}", consumes = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - void sendNotificationToUser(@RequestBody MessageRequest messageRequest); - - @PostMapping(value = "${rest-client.notification-manager.sendNotificationToUsers}", consumes = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - void sendNotificationToUsers(@RequestBody MultipleReceiverMessageRequest messageRequest); - -} diff --git a/connector/rest/src/main/java/it/pagopa/selfcare/mscore/connector/rest/config/NotificationManagerRestClientConfig.java b/connector/rest/src/main/java/it/pagopa/selfcare/mscore/connector/rest/config/NotificationManagerRestClientConfig.java deleted file mode 100644 index d5c17a53c..000000000 --- a/connector/rest/src/main/java/it/pagopa/selfcare/mscore/connector/rest/config/NotificationManagerRestClientConfig.java +++ /dev/null @@ -1,15 +0,0 @@ -package it.pagopa.selfcare.mscore.connector.rest.config; - -import it.pagopa.selfcare.commons.connector.rest.config.RestClientBaseConfig; -import it.pagopa.selfcare.mscore.connector.rest.client.NotificationManagerRestClient; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.context.annotation.PropertySource; - -@Configuration -@Import(RestClientBaseConfig.class) -@EnableFeignClients(clients = NotificationManagerRestClient.class) -@PropertySource("classpath:config/notification-manager-rest-client.properties") -public class NotificationManagerRestClientConfig { -} \ No newline at end of file diff --git a/connector/rest/src/main/resources/config/notification-manager-rest-client.properties b/connector/rest/src/main/resources/config/notification-manager-rest-client.properties deleted file mode 100644 index 2dba9ba67..000000000 --- a/connector/rest/src/main/resources/config/notification-manager-rest-client.properties +++ /dev/null @@ -1,5 +0,0 @@ -rest-client.notification-manager.serviceCode=notification-manager -rest-client.notification-manager.base-url=${MS_NOTIFICATION_MANAGER_URL}/notifications/v1 -rest-client.notification-manager.sendNotificationToUser=/user -rest-client.notification-manager.sendNotificationToUsers=/users -feign.client.config.notification-manager.requestInterceptors[0]=it.pagopa.selfcare.commons.connector.rest.interceptor.AuthorizationHeaderInterceptor \ No newline at end of file diff --git a/core/pom.xml b/core/pom.xml index 732bdfd6a..ff21c0886 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -77,6 +77,12 @@ io.github.openfeign feign-core + + + software.amazon.awssdk + ses + 2.20.88 + diff --git a/core/src/main/java/it/pagopa/selfcare/mscore/core/UserNotificationServiceImpl.java b/core/src/main/java/it/pagopa/selfcare/mscore/core/UserNotificationServiceImpl.java index 9c5116bbc..13c212e1e 100644 --- a/core/src/main/java/it/pagopa/selfcare/mscore/core/UserNotificationServiceImpl.java +++ b/core/src/main/java/it/pagopa/selfcare/mscore/core/UserNotificationServiceImpl.java @@ -2,14 +2,15 @@ import com.fasterxml.jackson.databind.ObjectMapper; import it.pagopa.selfcare.mscore.api.FileStorageConnector; -import it.pagopa.selfcare.mscore.api.NotificationServiceConnector; -import it.pagopa.selfcare.mscore.model.notification.MultipleReceiverMessageRequest; +import it.pagopa.selfcare.mscore.config.CoreConfig; import it.pagopa.selfcare.mscore.model.onboarding.MailTemplate; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.text.StringSubstitutor; import org.springframework.mail.MailPreparationException; import org.springframework.stereotype.Service; +import software.amazon.awssdk.services.ses.SesClient; +import software.amazon.awssdk.services.ses.model.*; import java.util.List; import java.util.Map; @@ -19,25 +20,9 @@ @RequiredArgsConstructor public class UserNotificationServiceImpl implements UserNotificationService { - private static final String ACTIVATE_SUBJECT = "Il tuo ruolo è stato riabilitato"; - private static final String DELETE_SUBJECT = "Il tuo ruolo è stato rimosso"; - private static final String SUSPEND_SUBJECT = "Il tuo ruolo è sospeso"; - private static final String CREATE_SUBJECT = "Hai un nuovo ruolo per un prodotto PagoPA"; - private static final String ACTIVATE_TEMPLATE = "user_activated.ftlh"; - private static final String DELETE_TEMPLATE = "user_deleted.ftlh"; - private static final String SUSPEND_TEMPLATE = "user_suspended.ftlh"; - private static final String CREATE_TEMPLATE_SINGLE_ROLE = "user_added_single_role.ftlh"; - private static final String CREATE_TEMPLATE_MULTIPLE_ROLE = "user_added_multi_role.ftlh"; - private static final String A_PRODUCT_TITLE_IS_REQUIRED = "A product Title is required"; - private static final String INSTITUTION_ID_IS_REQUIRED = "An institution id is required"; - private static final String PRODUCT_ROLES_ARE_REQUIRED = "ProductRoles are required"; - private static final String NAME_IS_REQUIRED = "RequesterName is required"; - - private static final String SURNAME_IS_REQUIRED = "RequesterSurname is required"; - - - private final NotificationServiceConnector notificationConnector; + private final CoreConfig coreConfig; + private final SesClient sesClient; private final FileStorageConnector fileStorageConnector; private final ObjectMapper mapper; @@ -48,12 +33,36 @@ public void sendDelegationUserNotification(List to, String templateName, MailTemplate mailTemplate = mapper.readValue(template, MailTemplate.class); String html = StringSubstitutor.replace(mailTemplate.getBody(), mailParameters); - MultipleReceiverMessageRequest messageRequest = new MultipleReceiverMessageRequest(); - messageRequest.setContent(html); - messageRequest.setReceiverEmails(to); - messageRequest.setSubject(productName + ": " + mailTemplate.getSubject()); - notificationConnector.sendNotificationToUsers(messageRequest); + Destination destination = Destination.builder() + .toAddresses(to) + .build(); + + Content content = Content.builder() + .data(html) + .build(); + + Content sub = Content.builder() + .data(productName + ": " + mailTemplate.getSubject()) + .build(); + + Body body = Body.builder() + .html(content) + .build(); + + Message msg = Message.builder() + .subject(sub) + .body(body) + .build(); + + SendEmailRequest emailRequest = SendEmailRequest.builder() + .destination(destination) + .message(msg) + .source(coreConfig.getSenderMail()) + .build(); + + sesClient.sendEmail(emailRequest); } catch (Exception e) { + log.error("Error sending mail to: {} for product: {}", String.join(",", to), productName); throw new MailPreparationException(e); } } diff --git a/core/src/main/java/it/pagopa/selfcare/mscore/core/config/MsCoreConfig.java b/core/src/main/java/it/pagopa/selfcare/mscore/core/config/MsCoreConfig.java index 98d961902..0481a4de3 100644 --- a/core/src/main/java/it/pagopa/selfcare/mscore/core/config/MsCoreConfig.java +++ b/core/src/main/java/it/pagopa/selfcare/mscore/core/config/MsCoreConfig.java @@ -8,6 +8,10 @@ import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; +import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; +import software.amazon.awssdk.regions.Region; +import software.amazon.awssdk.services.ses.SesClient; @Configuration @RequiredArgsConstructor @@ -24,4 +28,17 @@ public ProductService productService(){ throw new IllegalArgumentException("Found an issue when trying to serialize product json string!!"); } } + + @Bean + public SesClient sesClient() { + + StaticCredentialsProvider staticCredentials = StaticCredentialsProvider + .create(AwsBasicCredentials.create(config.getAwsSesSecretId(), config.getAwsSesSecretKey())); + + return SesClient.builder() + .region(Region.of(config.getAwsSesRegion())) + .credentialsProvider(staticCredentials) + .build(); + } + } diff --git a/core/src/main/java/it/pagopa/selfcare/mscore/core/util/MailParametersMapper.java b/core/src/main/java/it/pagopa/selfcare/mscore/core/util/MailParametersMapper.java index b42876ec7..0b8458072 100644 --- a/core/src/main/java/it/pagopa/selfcare/mscore/core/util/MailParametersMapper.java +++ b/core/src/main/java/it/pagopa/selfcare/mscore/core/util/MailParametersMapper.java @@ -1,13 +1,10 @@ package it.pagopa.selfcare.mscore.core.util; import it.pagopa.selfcare.mscore.config.MailTemplateConfig; -import it.pagopa.selfcare.mscore.model.onboarding.OnboardingRequest; -import it.pagopa.selfcare.mscore.model.user.User; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.HashMap; -import java.util.List; import java.util.Map; @Component @@ -16,58 +13,6 @@ public class MailParametersMapper { @Autowired MailTemplateConfig mailTemplateConfig; - public Map getOnboardingMailParameter(User user, OnboardingRequest request, String token, String description, boolean fromApprove) { - Map map = new HashMap<>(); - map.put(mailTemplateConfig.getProductName(), request.getProductName()); - if (fromApprove) { - map.put(mailTemplateConfig.getUserName(), description); - map.put(mailTemplateConfig.getUserSurname(), ""); - } else { - if (user.getName() != null) { - map.put(mailTemplateConfig.getUserName(), user.getName()); - } - if (user.getFamilyName() != null) { - map.put(mailTemplateConfig.getUserSurname(), user.getFamilyName()); - } - } - StringBuilder confirmLink = new StringBuilder(mailTemplateConfig.getConfirmTokenPlaceholder()); - StringBuilder rejectLink = new StringBuilder(mailTemplateConfig.getRejectTokenPlaceholder()); - map.put(mailTemplateConfig.getRejectTokenName(), rejectLink.append(token).toString()); - map.put(mailTemplateConfig.getConfirmTokenName(), confirmLink.append(token).toString()); - return map; - } - - public Map getOnboardingMailNotificationParameter(User user, OnboardingRequest request, String token) { - Map map = new HashMap<>(); - map.put(mailTemplateConfig.getNotificationProductName(), request.getProductName()); - if(user.getName()!=null) { - map.put(mailTemplateConfig.getNotificationRequesterName(), user.getName()); - } - if(user.getFamilyName()!=null) { - map.put(mailTemplateConfig.getNotificationRequesterSurname(), user.getFamilyName()); - } - if(request.getInstitutionUpdate()!=null) { - map.put(mailTemplateConfig.getInstitutionDescription(), request.getInstitutionUpdate().getDescription()); - } - StringBuilder adminApproveLink = new StringBuilder(mailTemplateConfig.getAdminLink()); - map.put(mailTemplateConfig.getConfirmTokenName(), adminApproveLink.append(token).toString()); - return map; - } - - public Map getRegistrationRequestParameter(User user, OnboardingRequest request) { - Map map = new HashMap<>(); - if(user.getName()!=null) { - map.put(mailTemplateConfig.getNotificationRequesterName(), user.getName()); - } - if(user.getFamilyName()!=null) { - map.put(mailTemplateConfig.getNotificationRequesterSurname(), user.getFamilyName()); - } - if(request.getInstitutionUpdate()!=null) { - map.put(mailTemplateConfig.getInstitutionDescription(), request.getInstitutionUpdate().getDescription()); - } - return map; - } - public Map getDelegationNotificationParameter(String institutionName, String productName, String partnerName) { Map map = new HashMap<>(); map.put(mailTemplateConfig.getNotificationProductName(), productName); @@ -76,18 +21,6 @@ public Map getDelegationNotificationParameter(String institution return map; } - public String getOnboardingNotificationPath() { - return mailTemplateConfig.getNotificationPath(); - } - - public String getRegistrationRequestPath() { - return mailTemplateConfig.getRegistrationRequestPath(); - } - - public String getRegistrationNotificationAdminPath() { - return mailTemplateConfig.getRegistrationNotificationAdminPath(); - } - public String getDelegationNotificationPath() { return mailTemplateConfig.getDelegationNotificationPath(); } @@ -96,34 +29,4 @@ public String getDelegationUserNotificationPath() { return mailTemplateConfig.getDelegationUserNotificationPath(); } - public String getOnboardingCompletePath() { - return mailTemplateConfig.getCompletePath(); - } - - public String getFdOnboardingCompletePath(){ - return mailTemplateConfig.getCompletePathFd(); - } - - public List getOnboardingNotificationAdminEmail() { - return List.of(mailTemplateConfig.getNotificationAdminEmail()); - } - - public Map getCompleteOnbordingMailParameter(String productName) { - Map map = new HashMap<>(); - map.put(mailTemplateConfig.getCompleteProductName(), productName); - map.put(mailTemplateConfig.getCompleteSelfcareName(), mailTemplateConfig.getCompleteSelfcarePlaceholder()); - return map; - } - - public Map getOnboardingRejectMailParameters(String productName, String productId){ - Map map = new HashMap<>(); - map.put(mailTemplateConfig.getRejectProductName(), productName); - map.put(mailTemplateConfig.getRejectOnboardingUrlPlaceholder(), mailTemplateConfig.getRejectOnboardingUrlValue() + productId); - return map; - } - - public String getOnboardingRejectNotificationPath(){ - return mailTemplateConfig.getRejectPath(); - } - } diff --git a/core/src/test/java/it/pagopa/selfcare/mscore/core/UserNotificationServiceImplTest.java b/core/src/test/java/it/pagopa/selfcare/mscore/core/UserNotificationServiceImplTest.java index c637611ad..f3619c39a 100644 --- a/core/src/test/java/it/pagopa/selfcare/mscore/core/UserNotificationServiceImplTest.java +++ b/core/src/test/java/it/pagopa/selfcare/mscore/core/UserNotificationServiceImplTest.java @@ -3,13 +3,16 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import it.pagopa.selfcare.mscore.api.FileStorageConnector; -import it.pagopa.selfcare.mscore.api.NotificationServiceConnector; +import it.pagopa.selfcare.mscore.config.CoreConfig; import it.pagopa.selfcare.mscore.model.onboarding.MailTemplate; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.ArgumentCaptor; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import software.amazon.awssdk.services.ses.SesClient; +import software.amazon.awssdk.services.ses.model.SendEmailRequest; import java.nio.charset.StandardCharsets; import java.util.Base64; @@ -17,9 +20,10 @@ import java.util.List; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.when; +import static org.mockito.Mockito.*; @ExtendWith(MockitoExtension.class) class UserNotificationServiceImplTest { @@ -27,23 +31,31 @@ class UserNotificationServiceImplTest { @InjectMocks private UserNotificationServiceImpl userNotificationService; - @Mock - private NotificationServiceConnector notificationConnector; - @Mock private FileStorageConnector fileStorageConnector; @Mock private ObjectMapper objectMapper; + @Mock + private CoreConfig coreConfig; + + @Mock + private SesClient sesClient; + @Test void sendDelegationUserNotification() throws JsonProcessingException { + final String to = "id"; when(fileStorageConnector.getTemplateFile(any())).thenReturn("template"); MailTemplate mailTemplate = new MailTemplate(); mailTemplate.setBody(Base64.getEncoder().encodeToString("test".getBytes(StandardCharsets.UTF_8))); mailTemplate.setSubject(Base64.getEncoder().encodeToString("test".getBytes(StandardCharsets.UTF_8))); - when(objectMapper.readValue(anyString(),(Class) any())).thenReturn(mailTemplate); - assertDoesNotThrow(() -> userNotificationService.sendDelegationUserNotification(List.of("id"),"institution","product", new HashMap<>())); + when(objectMapper.readValue(anyString(),any(Class.class))).thenReturn(mailTemplate); + assertDoesNotThrow(() -> userNotificationService.sendDelegationUserNotification(List.of(to),"institution","product", new HashMap<>())); + + ArgumentCaptor actual = ArgumentCaptor.forClass(SendEmailRequest.class); + verify(sesClient, times(1)).sendEmail(actual.capture()); + assertEquals(to, actual.getValue().destination().toAddresses().get(0)); } } diff --git a/core/src/test/java/it/pagopa/selfcare/mscore/core/util/MailParametersMapperTest.java b/core/src/test/java/it/pagopa/selfcare/mscore/core/util/MailParametersMapperTest.java index 3b0f194be..e31ef9c12 100644 --- a/core/src/test/java/it/pagopa/selfcare/mscore/core/util/MailParametersMapperTest.java +++ b/core/src/test/java/it/pagopa/selfcare/mscore/core/util/MailParametersMapperTest.java @@ -1,10 +1,6 @@ package it.pagopa.selfcare.mscore.core.util; import it.pagopa.selfcare.mscore.config.MailTemplateConfig; -import it.pagopa.selfcare.mscore.model.CertifiedField; -import it.pagopa.selfcare.mscore.model.institution.InstitutionUpdate; -import it.pagopa.selfcare.mscore.model.onboarding.OnboardingRequest; -import it.pagopa.selfcare.mscore.model.user.User; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -12,8 +8,6 @@ import org.mockito.Mock; import org.springframework.test.context.junit.jupiter.SpringExtension; -import java.util.Map; - import static org.mockito.Mockito.when; @ExtendWith(SpringExtension.class) @@ -25,130 +19,12 @@ class MailParametersMapperTest { @Mock private MailTemplateConfig mailTemplateConfig; - @Test - void getOnboardingMailParameter(){ - when(mailTemplateConfig.getProductName()).thenReturn("productName"); - when(mailTemplateConfig.getUserName()).thenReturn("userName"); - when(mailTemplateConfig.getUserSurname()).thenReturn("userSurname"); - when(mailTemplateConfig.getRejectTokenName()).thenReturn("rejectTokenName"); - when(mailTemplateConfig.getRejectTokenPlaceholder()).thenReturn("rejectTokenPlaceholder"); - when(mailTemplateConfig.getConfirmTokenName()).thenReturn("confirmTokenName"); - when(mailTemplateConfig.getConfirmTokenPlaceholder()).thenReturn("confirmTokenPlaceholder"); - User user = new User(); - CertifiedField certifiedField = new CertifiedField(); - certifiedField.setValue("val"); - user.setName(certifiedField); - user.setFamilyName(certifiedField); - OnboardingRequest request = new OnboardingRequest(); - request.setProductId("productId"); - Map map = mailParametersMapper.getOnboardingMailParameter(user, request, "token", "description", false); - Assertions.assertNotNull(map); - } - - - @Test - void getOnboardingMailNotificationParameter(){ - when(mailTemplateConfig.getProductName()).thenReturn("productName"); - when(mailTemplateConfig.getUserName()).thenReturn("userName"); - when(mailTemplateConfig.getUserSurname()).thenReturn("userSurname"); - when(mailTemplateConfig.getRejectTokenName()).thenReturn("rejectTokenName"); - when(mailTemplateConfig.getRejectTokenPlaceholder()).thenReturn("rejectTokenPlaceholder"); - when(mailTemplateConfig.getConfirmTokenName()).thenReturn("confirmTokenName"); - when(mailTemplateConfig.getConfirmTokenPlaceholder()).thenReturn("confirmTokenPlaceholder"); - when(mailTemplateConfig.getInstitutionDescription()).thenReturn("institutionDescription"); - when(mailTemplateConfig.getAdminLink()).thenReturn("institutionDescription"); - User user = new User(); - CertifiedField certifiedField = new CertifiedField<>(); - certifiedField.setValue("42"); - user.setName(certifiedField); - user.setFamilyName(certifiedField); - OnboardingRequest request = new OnboardingRequest(); - request.setProductId("productId"); - request.setInstitutionUpdate(new InstitutionUpdate()); - Map map = mailParametersMapper.getOnboardingMailNotificationParameter(user, request, ""); - Assertions.assertNotNull(map); - } - - @Test - void getRegistrationRequestParameter(){ - when(mailTemplateConfig.getUserName()).thenReturn("userName"); - when(mailTemplateConfig.getUserSurname()).thenReturn("userSurname"); - when(mailTemplateConfig.getInstitutionDescription()).thenReturn("institutionDescription"); - when(mailTemplateConfig.getAdminLink()).thenReturn("institutionDescription"); - User user = new User(); - CertifiedField certifiedField = new CertifiedField<>(); - certifiedField.setValue("42"); - user.setName(certifiedField); - user.setFamilyName(certifiedField); - OnboardingRequest request = new OnboardingRequest(); - request.setProductId("productId"); - request.setInstitutionUpdate(new InstitutionUpdate()); - Map map = mailParametersMapper.getRegistrationRequestParameter(user, request); - Assertions.assertNotNull(map); - } - - @Test - void getOnboardingNotificationPath(){ - when(mailTemplateConfig.getNotificationPath()).thenReturn("path"); - Assertions.assertNotNull(mailParametersMapper.getOnboardingNotificationPath()); - } - @Test void getNotificationDelegationPath(){ when(mailTemplateConfig.getDelegationNotificationPath()).thenReturn("path"); Assertions.assertNotNull(mailParametersMapper.getDelegationNotificationPath()); } - @Test - void getRegistrationRequestPath(){ - when(mailTemplateConfig.getRegistrationRequestPath()).thenReturn("path"); - Assertions.assertNotNull(mailParametersMapper.getRegistrationRequestPath()); - } - - @Test - void getRegistrationNotificationPath(){ - when(mailTemplateConfig.getRegistrationNotificationAdminPath()).thenReturn("path"); - Assertions.assertNotNull(mailParametersMapper.getRegistrationNotificationAdminPath()); - } - - @Test - void getOnboardingCompletePath(){ - when(mailTemplateConfig.getCompletePath()).thenReturn("path"); - Assertions.assertNotNull(mailParametersMapper.getOnboardingCompletePath()); - } - - @Test - void getCompleteOnbordingMailParameter(){ - when(mailTemplateConfig.getRejectProductName()).thenReturn("productName"); - when(mailTemplateConfig.getRejectOnboardingUrlPlaceholder()).thenReturn("getRejectOnboardingUrlPlaceholder"); - when(mailTemplateConfig.getRejectOnboardingUrlValue()).thenReturn("getRejectOnboardingUrlValue"); - - Assertions.assertNotNull(mailParametersMapper.getCompleteOnbordingMailParameter("productName")); - } - - @Test - void getOnboardingNotificationAdminEmail(){ - when(mailTemplateConfig.getNotificationAdminEmail()).thenReturn("admin"); - - Assertions.assertNotNull(mailParametersMapper.getOnboardingNotificationAdminEmail()); - } - - @Test - void getOnboardingRejectNotificationPath(){ - when(mailTemplateConfig.getRejectPath()).thenReturn("path"); - - Assertions.assertNotNull(mailParametersMapper.getOnboardingRejectNotificationPath()); - } - - @Test - void getOnboardingRejectMailParameters(){ - when(mailTemplateConfig.getRejectProductName()).thenReturn("path"); - when(mailTemplateConfig.getRejectOnboardingUrlPlaceholder()).thenReturn("path"); - when(mailTemplateConfig.getRejectOnboardingUrlValue()).thenReturn("path"); - - Assertions.assertNotNull(mailParametersMapper.getOnboardingRejectMailParameters("productName","productId")); - } - @Test void getNotificationDelegationParameters(){ Assertions.assertNotNull(mailParametersMapper.getDelegationNotificationParameter("productName","productId", "partnerName")); diff --git a/infra/container_apps/env/dev-pnpg/terraform.tfvars b/infra/container_apps/env/dev-pnpg/terraform.tfvars index 2e0317299..370d9db8c 100644 --- a/infra/container_apps/env/dev-pnpg/terraform.tfvars +++ b/infra/container_apps/env/dev-pnpg/terraform.tfvars @@ -36,26 +36,10 @@ app_settings = [ value = "pectest@pec.pagopa.it" # //prod non presente }, - { - name = "MAIL_TEMPLATE_COMPLETE_PATH" - value = "contracts/template/mail/onboarding-complete/1.0.0.json" - }, - { - name = "MAIL_TEMPLATE_PT_COMPLETE_PATH" - value = "contracts/template/mail/registration-complete-pt/1.0.0.json" - }, - { - name = "MAIL_TEMPLATE_FD_COMPLETE_NOTIFICATION_PATH" - value = "contracts/template/mail/onboarding-complete-fd/1.0.0.json" - }, { name = "SELFCARE_URL" value = "https://selfcare.pagopa.it" }, - { - name = "MAIL_TEMPLATE_AUTOCOMPLETE_PATH" - value = "contracts/template/mail/import-massivo-io/1.0.0.json" - }, { name = "MAIL_TEMPLATE_DELEGATION_NOTIFICATION_PATH" value = "contracts/template/mail/delegation-notification/1.0.0.json" @@ -64,46 +48,6 @@ app_settings = [ name = "MAIL_TEMPLATE_DELEGATION_USER_NOTIFICATION_PATH" value = "contracts/template/mail/delegation-notification/user-1.0.0.json" }, - { - name = "MAIL_TEMPLATE_PATH" - value = "resources/templates/email/onboarding_1.0.0.json" //pnpg - }, - { - name = "MAIL_ONBOARDING_CONFIRMATION_LINK" - value = "https://dev.selfcare.pagopa.it/onboarding/confirm?jwt=" - }, - - { - name = "MAIL_ONBOARDING_REJECTION_LINK" - value = "https://dev.selfcare.pagopa.it/onboarding/cancel?jwt=" - }, - - { - name = "SELFCARE_ADMIN_NOTIFICATION_URL" - value = "https://dev.selfcare.pagopa.it/dashboard/admin/onboarding/" - }, - { - name = "MAIL_TEMPLATE_NOTIFICATION_PATH" - value = "contracts/template/mail/onboarding-notification/1.0.0.json" - }, - - { - name = "MAIL_TEMPLATE_REGISTRATION_REQUEST_PT_PATH" - value = "contracts/template/mail/registration-request-pt/1.0.0.json" - }, - - { - name = "MAIL_TEMPLATE_REGISTRATION_NOTIFICATION_ADMIN_PATH" - value = "contracts/template/mail/registration-notification-admin/1.0.0.json" - }, - { - name = "MAIL_TEMPLATE_REJECT_PATH" - value = "contracts/template/mail/onboarding-refused/1.0.0.json" - }, - { - name = "MAIL_ONBOARDING_URL" - value = "https://dev.selfcare.pagopa.it/onboarding/" - }, { name = "STORAGE_CONTAINER" value = "$web" @@ -181,14 +125,16 @@ app_settings = [ { name = "SELFCARE_USER_URL" value = "http://selc-d-pnpg-user-ms-ca" + }, + { + name = "MAIL_SENDER_ADDRESS" + value = "noreply@areariservata.pagopa.it" } ] secrets_names = { "STORAGE_APPLICATION_SECRET" = "contracts-storage-access-key" - "ADDRESS_EMAIL_NOTIFICATION_ADMIN" = "portal-admin-operator-email" "APPLICATIONINSIGHTS_CONNECTION_STRING" = "appinsights-connection-string" - "MAIL_SENDER_ADDRESS" = "smtp-usr" "MONGODB_CONNECTION_URI" = "mongodb-connection-string" "BLOB_STORAGE_CONN_STRING" = "blob-storage-contract-connection-string" "STORAGE_CREDENTIAL_SECRET" = "contracts-storage-access-key" @@ -198,4 +144,6 @@ secrets_names = { "USER_REGISTRY_API_KEY" = "user-registry-api-key" "JWT_TOKEN_PUBLIC_KEY" = "jwt-public-key" "BLOB_STORAGE_PRODUCT_CONNECTION_STRING" = "blob-storage-product-connection-string" + "AWS-SES-ACCESS-KEY-ID" = "aws-ses-access-key-id" + "AWS-SES-SECRET-ACCESS-KEY" = "aws-ses-secret-access-key" } \ No newline at end of file diff --git a/infra/container_apps/env/dev/terraform.tfvars b/infra/container_apps/env/dev/terraform.tfvars index bf0dc578c..9edc946fa 100644 --- a/infra/container_apps/env/dev/terraform.tfvars +++ b/infra/container_apps/env/dev/terraform.tfvars @@ -40,26 +40,10 @@ app_settings = [ # name = "ONBOARDING_SEND_EMAIL_TO_INSTITUTION" # value = "true" //solo prod Selfcare # }, - { - name = "MAIL_TEMPLATE_COMPLETE_PATH" - value = "contracts/template/mail/onboarding-complete/1.0.0.json" - }, - { - name = "MAIL_TEMPLATE_PT_COMPLETE_PATH" - value = "contracts/template/mail/registration-complete-pt/1.0.0.json" - }, - { - name = "MAIL_TEMPLATE_FD_COMPLETE_NOTIFICATION_PATH" - value = "contracts/template/mail/onboarding-complete-fd/1.0.0.json" - }, { name = "SELFCARE_URL" value = "https://selfcare.pagopa.it" }, - { - name = "MAIL_TEMPLATE_AUTOCOMPLETE_PATH" - value = "contracts/template/mail/import-massivo-io/1.0.0.json" - }, { name = "MAIL_TEMPLATE_DELEGATION_NOTIFICATION_PATH" value = "contracts/template/mail/delegation-notification/1.0.0.json" @@ -68,50 +52,6 @@ app_settings = [ name = "MAIL_TEMPLATE_DELEGATION_USER_NOTIFICATION_PATH" value = "contracts/template/mail/delegation-notification/user-1.0.0.json" }, - #{ - # name = "MAIL_TEMPLATE_PATH" - # value = "resources/templates/email/onboarding_1.0.0.json" //pnpg - #}, - { - name = "MAIL_TEMPLATE_PATH" - value = "contracts/template/mail/1.0.0.json" //selfcare - }, - { - name = "MAIL_ONBOARDING_CONFIRMATION_LINK" - value = "https://dev.selfcare.pagopa.it/onboarding/confirm?jwt=" - }, - - { - name = "MAIL_ONBOARDING_REJECTION_LINK" - value = "https://dev.selfcare.pagopa.it/onboarding/cancel?jwt=" - }, - - { - name = "SELFCARE_ADMIN_NOTIFICATION_URL" - value = "https://dev.selfcare.pagopa.it/dashboard/admin/onboarding/" - }, - { - name = "MAIL_TEMPLATE_NOTIFICATION_PATH" - value = "contracts/template/mail/onboarding-notification/1.0.0.json" - }, - - { - name = "MAIL_TEMPLATE_REGISTRATION_REQUEST_PT_PATH" - value = "contracts/template/mail/registration-request-pt/1.0.0.json" - }, - - { - name = "MAIL_TEMPLATE_REGISTRATION_NOTIFICATION_ADMIN_PATH" - value = "contracts/template/mail/registration-notification-admin/1.0.0.json" - }, - { - name = "MAIL_TEMPLATE_REJECT_PATH" - value = "contracts/template/mail/onboarding-refused/1.0.0.json" - }, - { - name = "MAIL_ONBOARDING_URL" - value = "https://dev.selfcare.pagopa.it/onboarding/" - }, { name = "STORAGE_CONTAINER" value = "selc-d-contracts-blob" @@ -201,14 +141,16 @@ app_settings = [ { name = "SELFCARE_USER_URL" value = "http://selc-d-user-ms-ca" + }, + { + name = "MAIL_SENDER_ADDRESS" + value = "noreply@areariservata.pagopa.it" } ] secrets_names = { "STORAGE_APPLICATION_SECRET" = "contracts-storage-access-key" - "ADDRESS_EMAIL_NOTIFICATION_ADMIN" = "portal-admin-operator-email" "APPLICATIONINSIGHTS_CONNECTION_STRING" = "appinsights-connection-string" - "MAIL_SENDER_ADDRESS" = "smtp-usr" "MONGODB_CONNECTION_URI" = "mongodb-connection-string" "BLOB_STORAGE_CONN_STRING" = "blob-storage-contract-connection-string" "STORAGE_CREDENTIAL_SECRET" = "contracts-storage-access-key" @@ -220,4 +162,6 @@ secrets_names = { "JWT_TOKEN_PUBLIC_KEY" = "jwt-public-key" "KAFKA_USERS_SELFCARE_WO_SASL_JAAS_CONFIG" = "eventhub-sc-users-selfcare-wo-connection-string-lc" "BLOB_STORAGE_PRODUCT_CONNECTION_STRING" = "blob-storage-product-connection-string" + "AWS-SES-ACCESS-KEY-ID" = "aws-ses-access-key-id" + "AWS-SES-SECRET-ACCESS-KEY" = "aws-ses-secret-access-key" } diff --git a/infra/container_apps/env/prod-pnpg/terraform.tfvars b/infra/container_apps/env/prod-pnpg/terraform.tfvars index 5d62c6122..7256269d3 100644 --- a/infra/container_apps/env/prod-pnpg/terraform.tfvars +++ b/infra/container_apps/env/prod-pnpg/terraform.tfvars @@ -31,26 +31,10 @@ container_app = { } app_settings = [ - { - name = "MAIL_TEMPLATE_COMPLETE_PATH" - value = "contracts/template/mail/onboarding-complete/1.0.0.json" - }, - { - name = "MAIL_TEMPLATE_PT_COMPLETE_PATH" - value = "contracts/template/mail/registration-complete-pt/1.0.0.json" - }, - { - name = "MAIL_TEMPLATE_FD_COMPLETE_NOTIFICATION_PATH" - value = "contracts/template/mail/onboarding-complete-fd/1.0.0.json" - }, { name = "SELFCARE_URL" value = "https://selfcare.pagopa.it" }, - { - name = "MAIL_TEMPLATE_AUTOCOMPLETE_PATH" - value = "contracts/template/mail/import-massivo-io/1.0.0.json" - }, { name = "MAIL_TEMPLATE_DELEGATION_NOTIFICATION_PATH" value = "contracts/template/mail/delegation-notification/1.0.0.json" @@ -59,46 +43,6 @@ app_settings = [ name = "MAIL_TEMPLATE_DELEGATION_USER_NOTIFICATION_PATH" value = "contracts/template/mail/delegation-notification/user-1.0.0.json" }, - { - name = "MAIL_TEMPLATE_PATH" - value = "resources/templates/email/onboarding_1.0.0.json" //pnpg - }, - { - name = "MAIL_ONBOARDING_CONFIRMATION_LINK" - value = "https://selfcare.pagopa.it/onboarding/confirm?jwt=" - }, - - { - name = "MAIL_ONBOARDING_REJECTION_LINK" - value = "https://selfcare.pagopa.it/onboarding/cancel?jwt=" - }, - - { - name = "SELFCARE_ADMIN_NOTIFICATION_URL" - value = "https://selfcare.pagopa.it/dashboard/admin/onboarding/" - }, - { - name = "MAIL_TEMPLATE_NOTIFICATION_PATH" - value = "contracts/template/mail/onboarding-notification/1.0.0.json" - }, - - { - name = "MAIL_TEMPLATE_REGISTRATION_REQUEST_PT_PATH" - value = "contracts/template/mail/registration-request-pt/1.0.0.json" - }, - - { - name = "MAIL_TEMPLATE_REGISTRATION_NOTIFICATION_ADMIN_PATH" - value = "contracts/template/mail/registration-notification-admin/1.0.0.json" - }, - { - name = "MAIL_TEMPLATE_REJECT_PATH" - value = "contracts/template/mail/onboarding-refused/1.0.0.json" - }, - { - name = "MAIL_ONBOARDING_URL" - value = "https://selfcare.pagopa.it/onboarding/" - }, { name = "STORAGE_CONTAINER" value = "$web" @@ -180,15 +124,17 @@ app_settings = [ { name = "PRODUCT_STORAGE_CONTAINER" value = "selc-p-product" + }, + { + name = "MAIL_SENDER_ADDRESS" + value = "noreply@areariservata.pagopa.it" } ] secrets_names = { "STORAGE_APPLICATION_SECRET" = "contracts-storage-access-key" - "ADDRESS_EMAIL_NOTIFICATION_ADMIN" = "portal-admin-operator-email" "APPLICATIONINSIGHTS_CONNECTION_STRING" = "appinsights-connection-string" - "MAIL_SENDER_ADDRESS" = "smtp-usr" "MONGODB_CONNECTION_URI" = "mongodb-connection-string" "BLOB_STORAGE_CONN_STRING" = "blob-storage-contract-connection-string" "STORAGE_CREDENTIAL_SECRET" = "contracts-storage-access-key" @@ -198,4 +144,6 @@ secrets_names = { "USER_REGISTRY_API_KEY" = "user-registry-api-key" "JWT_TOKEN_PUBLIC_KEY" = "jwt-public-key" "BLOB_STORAGE_PRODUCT_CONNECTION_STRING" = "blob-storage-product-connection-string" + "AWS-SES-ACCESS-KEY-ID" = "aws-ses-access-key-id" + "AWS-SES-SECRET-ACCESS-KEY" = "aws-ses-secret-access-key" } \ No newline at end of file diff --git a/infra/container_apps/env/prod/terraform.tfvars b/infra/container_apps/env/prod/terraform.tfvars index 0c45df018..d70a0a784 100644 --- a/infra/container_apps/env/prod/terraform.tfvars +++ b/infra/container_apps/env/prod/terraform.tfvars @@ -35,26 +35,10 @@ app_settings = [ name = "ONBOARDING_SEND_EMAIL_TO_INSTITUTION" value = "true" }, - { - name = "MAIL_TEMPLATE_COMPLETE_PATH" - value = "contracts/template/mail/onboarding-complete/1.0.0.json" - }, - { - name = "MAIL_TEMPLATE_PT_COMPLETE_PATH" - value = "contracts/template/mail/registration-complete-pt/1.0.0.json" - }, - { - name = "MAIL_TEMPLATE_FD_COMPLETE_NOTIFICATION_PATH" - value = "contracts/template/mail/onboarding-complete-fd/1.0.0.json" - }, { name = "SELFCARE_URL" value = "https://selfcare.pagopa.it" }, - { - name = "MAIL_TEMPLATE_AUTOCOMPLETE_PATH" - value = "contracts/template/mail/import-massivo-io/1.0.0.json" - }, { name = "MAIL_TEMPLATE_DELEGATION_NOTIFICATION_PATH" value = "contracts/template/mail/delegation-notification/1.0.0.json" @@ -63,46 +47,6 @@ app_settings = [ name = "MAIL_TEMPLATE_DELEGATION_USER_NOTIFICATION_PATH" value = "contracts/template/mail/delegation-notification/user-1.0.0.json" }, - { - name = "MAIL_TEMPLATE_PATH" - value = "contracts/template/mail/1.0.0.json" //selfcare - }, - { - name = "MAIL_ONBOARDING_CONFIRMATION_LINK" - value = "https://selfcare.pagopa.it/onboarding/confirm?jwt=" - }, - - { - name = "MAIL_ONBOARDING_REJECTION_LINK" - value = "https://selfcare.pagopa.it/onboarding/cancel?jwt=" - }, - - { - name = "SELFCARE_ADMIN_NOTIFICATION_URL" - value = "https://selfcare.pagopa.it/dashboard/admin/onboarding/" - }, - { - name = "MAIL_TEMPLATE_NOTIFICATION_PATH" - value = "contracts/template/mail/onboarding-notification/1.0.0.json" - }, - - { - name = "MAIL_TEMPLATE_REGISTRATION_REQUEST_PT_PATH" - value = "contracts/template/mail/registration-request-pt/1.0.0.json" - }, - - { - name = "MAIL_TEMPLATE_REGISTRATION_NOTIFICATION_ADMIN_PATH" - value = "contracts/template/mail/registration-notification-admin/1.0.0.json" - }, - { - name = "MAIL_TEMPLATE_REJECT_PATH" - value = "contracts/template/mail/onboarding-refused/1.0.0.json" - }, - { - name = "MAIL_ONBOARDING_URL" - value = "https://selfcare.pagopa.it/onboarding/" - }, { name = "STORAGE_CONTAINER" value = "selc-p-contracts-blob" @@ -193,14 +137,16 @@ app_settings = [ { name = "PRODUCT_STORAGE_CONTAINER" value = "selc-p-product" + }, + { + name = "MAIL_SENDER_ADDRESS" + value = "noreply@areariservata.pagopa.it" } ] secrets_names = { "STORAGE_APPLICATION_SECRET" = "contracts-storage-access-key" - "ADDRESS_EMAIL_NOTIFICATION_ADMIN" = "portal-admin-operator-email" "APPLICATIONINSIGHTS_CONNECTION_STRING" = "appinsights-connection-string" - "MAIL_SENDER_ADDRESS" = "smtp-usr" "MONGODB_CONNECTION_URI" = "mongodb-connection-string" "BLOB_STORAGE_CONN_STRING" = "blob-storage-contract-connection-string" "STORAGE_CREDENTIAL_SECRET" = "contracts-storage-access-key" @@ -212,4 +158,6 @@ secrets_names = { "JWT_TOKEN_PUBLIC_KEY" = "jwt-public-key" "KAFKA_USERS_SELFCARE_WO_SASL_JAAS_CONFIG" = "eventhub-sc-users-selfcare-wo-connection-string-lc" "BLOB_STORAGE_PRODUCT_CONNECTION_STRING" = "blob-storage-product-connection-string" + "AWS-SES-ACCESS-KEY-ID" = "aws-ses-access-key-id" + "AWS-SES-SECRET-ACCESS-KEY" = "aws-ses-secret-access-key" } \ No newline at end of file diff --git a/infra/container_apps/env/uat-pnpg/terraform.tfvars b/infra/container_apps/env/uat-pnpg/terraform.tfvars index a5ad2892a..d5c11db24 100644 --- a/infra/container_apps/env/uat-pnpg/terraform.tfvars +++ b/infra/container_apps/env/uat-pnpg/terraform.tfvars @@ -24,26 +24,10 @@ app_settings = [ name = "DESTINATION_MAILS" value = "pectest@pec.pagopa.it" }, - { - name = "MAIL_TEMPLATE_COMPLETE_PATH" - value = "contracts/template/mail/onboarding-complete/1.0.0.json" - }, - { - name = "MAIL_TEMPLATE_PT_COMPLETE_PATH" - value = "contracts/template/mail/registration-complete-pt/1.0.0.json" - }, - { - name = "MAIL_TEMPLATE_FD_COMPLETE_NOTIFICATION_PATH" - value = "contracts/template/mail/onboarding-complete-fd/1.0.0.json" - }, { name = "SELFCARE_URL" value = "https://selfcare.pagopa.it" }, - { - name = "MAIL_TEMPLATE_AUTOCOMPLETE_PATH" - value = "contracts/template/mail/import-massivo-io/1.0.0.json" - }, { name = "MAIL_TEMPLATE_DELEGATION_NOTIFICATION_PATH" value = "contracts/template/mail/delegation-notification/1.0.0.json" @@ -52,46 +36,6 @@ app_settings = [ name = "MAIL_TEMPLATE_DELEGATION_USER_NOTIFICATION_PATH" value = "contracts/template/mail/delegation-notification/user-1.0.0.json" }, - { - name = "MAIL_TEMPLATE_PATH" - value = "resources/templates/email/onboarding_1.0.0.json" //pnpg - }, - { - name = "MAIL_ONBOARDING_CONFIRMATION_LINK" - value = "https://uat.selfcare.pagopa.it/onboarding/confirm?jwt=" - }, - - { - name = "MAIL_ONBOARDING_REJECTION_LINK" - value = "https://uat.selfcare.pagopa.it/onboarding/cancel?jwt=" - }, - - { - name = "SELFCARE_ADMIN_NOTIFICATION_URL" - value = "https://uat.selfcare.pagopa.it/dashboard/admin/onboarding/" - }, - { - name = "MAIL_TEMPLATE_NOTIFICATION_PATH" - value = "contracts/template/mail/onboarding-notification/1.0.0.json" - }, - - { - name = "MAIL_TEMPLATE_REGISTRATION_REQUEST_PT_PATH" - value = "contracts/template/mail/registration-request-pt/1.0.0.json" - }, - - { - name = "MAIL_TEMPLATE_REGISTRATION_NOTIFICATION_ADMIN_PATH" - value = "contracts/template/mail/registration-notification-admin/1.0.0.json" - }, - { - name = "MAIL_TEMPLATE_REJECT_PATH" - value = "contracts/template/mail/onboarding-refused/1.0.0.json" - }, - { - name = "MAIL_ONBOARDING_URL" - value = "https://uat.selfcare.pagopa.it/onboarding/" - }, { name = "STORAGE_CONTAINER" value = "$web" @@ -173,14 +117,16 @@ app_settings = [ { name = "PRODUCT_STORAGE_CONTAINER" value = "selc-u-product" + }, + { + name = "MAIL_SENDER_ADDRESS" + value = "noreply@areariservata.pagopa.it" } ] secrets_names = { "STORAGE_APPLICATION_SECRET" = "contracts-storage-access-key" - "ADDRESS_EMAIL_NOTIFICATION_ADMIN" = "portal-admin-operator-email" "APPLICATIONINSIGHTS_CONNECTION_STRING" = "appinsights-connection-string" - "MAIL_SENDER_ADDRESS" = "smtp-usr" "MONGODB_CONNECTION_URI" = "mongodb-connection-string" "BLOB_STORAGE_CONN_STRING" = "blob-storage-contract-connection-string" "STORAGE_CREDENTIAL_SECRET" = "contracts-storage-access-key" @@ -189,5 +135,7 @@ secrets_names = { "ONBOARDING_INSTITUTION_ALTERNATIVE_EMAIL" = "party-test-institution-email" "USER_REGISTRY_API_KEY" = "user-registry-api-key" "JWT_TOKEN_PUBLIC_KEY" = "jwt-public-key" - "BLOB_STORAGE_PRODUCT_CONNECTION_STRING" = "blob-storage-product-connection-string" + "BLOB_STORAGE_PRODUCT_CONNECTION_STRING" = "blob-storage-product-connection-string" + "AWS-SES-ACCESS-KEY-ID" = "aws-ses-access-key-id" + "AWS-SES-SECRET-ACCESS-KEY" = "aws-ses-secret-access-key" } \ No newline at end of file diff --git a/infra/container_apps/env/uat/terraform.tfvars b/infra/container_apps/env/uat/terraform.tfvars index c3861ae52..74f290983 100644 --- a/infra/container_apps/env/uat/terraform.tfvars +++ b/infra/container_apps/env/uat/terraform.tfvars @@ -25,26 +25,10 @@ app_settings = [ value = "pectest@pec.pagopa.it" # //prod non presente }, - { - name = "MAIL_TEMPLATE_COMPLETE_PATH" - value = "contracts/template/mail/onboarding-complete/1.0.0.json" - }, - { - name = "MAIL_TEMPLATE_PT_COMPLETE_PATH" - value = "contracts/template/mail/registration-complete-pt/1.0.0.json" - }, - { - name = "MAIL_TEMPLATE_FD_COMPLETE_NOTIFICATION_PATH" - value = "contracts/template/mail/onboarding-complete-fd/1.0.0.json" - }, { name = "SELFCARE_URL" value = "https://selfcare.pagopa.it" }, - { - name = "MAIL_TEMPLATE_AUTOCOMPLETE_PATH" - value = "contracts/template/mail/import-massivo-io/1.0.0.json" - }, { name = "MAIL_TEMPLATE_DELEGATION_NOTIFICATION_PATH" value = "contracts/template/mail/delegation-notification/1.0.0.json" @@ -53,46 +37,6 @@ app_settings = [ name = "MAIL_TEMPLATE_DELEGATION_USER_NOTIFICATION_PATH" value = "contracts/template/mail/delegation-notification/user-1.0.0.json" }, - { - name = "MAIL_TEMPLATE_PATH" - value = "contracts/template/mail/1.0.0.json" //selfcare - }, - { - name = "MAIL_ONBOARDING_CONFIRMATION_LINK" - value = "https://uat.selfcare.pagopa.it/onboarding/confirm?jwt=" - }, - - { - name = "MAIL_ONBOARDING_REJECTION_LINK" - value = "https://uat.selfcare.pagopa.it/onboarding/cancel?jwt=" - }, - - { - name = "SELFCARE_ADMIN_NOTIFICATION_URL" - value = "https://uat.selfcare.pagopa.it/dashboard/admin/onboarding/" - }, - { - name = "MAIL_TEMPLATE_NOTIFICATION_PATH" - value = "contracts/template/mail/onboarding-notification/1.0.0.json" - }, - - { - name = "MAIL_TEMPLATE_REGISTRATION_REQUEST_PT_PATH" - value = "contracts/template/mail/registration-request-pt/1.0.0.json" - }, - - { - name = "MAIL_TEMPLATE_REGISTRATION_NOTIFICATION_ADMIN_PATH" - value = "contracts/template/mail/registration-notification-admin/1.0.0.json" - }, - { - name = "MAIL_TEMPLATE_REJECT_PATH" - value = "contracts/template/mail/onboarding-refused/1.0.0.json" - }, - { - name = "MAIL_ONBOARDING_URL" - value = "https://uat.selfcare.pagopa.it/onboarding/" - }, { name = "STORAGE_CONTAINER" value = "selc-u-contracts-blob" @@ -184,14 +128,16 @@ app_settings = [ { name = "PRODUCT_STORAGE_CONTAINER" value = "selc-u-product" + }, + { + name = "MAIL_SENDER_ADDRESS" + value = "noreply@areariservata.pagopa.it" } ] secrets_names = { "STORAGE_APPLICATION_SECRET" = "contracts-storage-access-key" - "ADDRESS_EMAIL_NOTIFICATION_ADMIN" = "portal-admin-operator-email" "APPLICATIONINSIGHTS_CONNECTION_STRING" = "appinsights-connection-string" - "MAIL_SENDER_ADDRESS" = "smtp-usr" "MONGODB_CONNECTION_URI" = "mongodb-connection-string" "BLOB_STORAGE_CONN_STRING" = "blob-storage-contract-connection-string" "STORAGE_CREDENTIAL_SECRET" = "contracts-storage-access-key" @@ -203,4 +149,6 @@ secrets_names = { "JWT_TOKEN_PUBLIC_KEY" = "jwt-public-key" "KAFKA_USERS_SELFCARE_WO_SASL_JAAS_CONFIG" = "eventhub-sc-users-selfcare-wo-connection-string-lc" "BLOB_STORAGE_PRODUCT_CONNECTION_STRING" = "blob-storage-product-connection-string" + "AWS-SES-ACCESS-KEY-ID" = "aws-ses-access-key-id" + "AWS-SES-SECRET-ACCESS-KEY" = "aws-ses-secret-access-key" }