messages sent to 'registeredBy' email are now sent to the currently authenticated user as well
This commit is contained in:
parent
d3bcea79c0
commit
287f476bd2
|
@ -5,6 +5,7 @@ import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
|||
import eu.dnetlib.repo.manager.domain.InterfaceComplianceRequest;
|
||||
import eu.dnetlib.repo.manager.domain.Repository;
|
||||
import eu.dnetlib.repo.manager.domain.RepositoryInterface;
|
||||
import eu.dnetlib.repo.manager.domain.dto.User;
|
||||
import eu.dnetlib.repo.manager.exception.ValidationServiceException;
|
||||
import eu.dnetlib.utils.MailLibrary;
|
||||
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
||||
|
@ -17,8 +18,7 @@ import org.springframework.security.core.Authentication;
|
|||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component("emailUtils")
|
||||
|
@ -259,7 +259,12 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
"This message has been generated automatically.";
|
||||
message = createUserMail(message, authentication);
|
||||
|
||||
this.sendMail(repository.getRegisteredby(), subject, message);
|
||||
Collection<String> emailTo = new HashSet<>();
|
||||
if (repository.getRegisteredby() != null) {
|
||||
emailTo.add(repository.getRegisteredby());
|
||||
}
|
||||
emailTo.add(User.from(((OIDCAuthenticationToken) authentication).getUserInfo()).getEmail());
|
||||
this.sendMail(emailTo, subject, message);
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Error while sending registration of interface notification email to user: " + repository.getRegisteredby(), e);
|
||||
|
@ -288,7 +293,12 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
||||
message = createUserMail(message, authentication);
|
||||
|
||||
this.sendMail(repository.getRegisteredby(), subject, message);
|
||||
Collection<String> emailTo = new HashSet<>();
|
||||
if (repository.getRegisteredby() != null) {
|
||||
emailTo.add(repository.getRegisteredby());
|
||||
}
|
||||
emailTo.add(User.from(((OIDCAuthenticationToken) authentication).getUserInfo()).getEmail());
|
||||
this.sendMail(emailTo, subject, message);
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Error while sending registration notification email to user: " + repository.getRegisteredby(), e);
|
||||
|
@ -346,7 +356,12 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
"If you have any questions, write to 'helpdesk@openaire.eu'.";
|
||||
message = createUserMail(message, authentication);
|
||||
|
||||
this.sendMail(repository.getRegisteredby(), subject, message);
|
||||
Collection<String> emailTo = new HashSet<>();
|
||||
if (repository.getRegisteredby() != null) {
|
||||
emailTo.add(repository.getRegisteredby());
|
||||
}
|
||||
emailTo.add(User.from(((OIDCAuthenticationToken) authentication).getUserInfo()).getEmail());
|
||||
this.sendMail(emailTo, subject, message);
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Error while sending registration notification email to user: " + repository.getRegisteredby(), e);
|
||||
|
@ -781,7 +796,7 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
this.sendMail(Collections.singletonList(email), subject, message);
|
||||
}
|
||||
|
||||
public void sendMail(List<String> recipients, String subject, String message) {
|
||||
public void sendMail(Collection<String> recipients, String subject, String message) {
|
||||
try {
|
||||
logger.debug("Sending e-mail\nRecipients: {}\nSubject: {}\nMessage: {}", recipients, subject, message);
|
||||
mailLibrary.sendEmail(recipients.toArray(new String[]{}), subject, message);
|
||||
|
|
Loading…
Reference in New Issue