Commit 1833081e authored by Matija Obreza's avatar Matija Obreza
Browse files

Emails to institutes are CC'd to default email address

parent 74749679
......@@ -17,7 +17,10 @@
package org.genesys2.server.service;
public interface EMailService {
void sendMail(String mailSubject, String mailBody, String ... emailTo);
void sendMail(String mailSubject, String mailBody, String[] emailCc, String ... emailTo);
void sendMail(String email, String name, String mailSubject, String mailBody);
}
......@@ -52,12 +52,16 @@ public class EMailServiceImpl implements EMailService {
private String emailFrom;
@Override
public void sendMail(String email, String name, String mailSubject, String mailBody) {
public void sendMail(String mailSubject, String mailBody, String... emailTo) {
sendMail(mailSubject, mailBody, null, emailTo);
}
sendSimpleEmail(mailSubject, mailBody, emailFrom, email);
@Override
public void sendMail(String mailSubject, String mailBody, String[] emailCc, String... emailTo) {
sendSimpleEmail(mailSubject, mailBody, emailFrom, emailCc, emailTo);
}
public void sendSimpleEmail(final String subject, final String text, final String emailFrom, final String... emailTo) {
public void sendSimpleEmail(final String subject, final String text, final String emailFrom, final String[] emailCc, final String... emailTo) {
printDebugInfo(subject, text, emailFrom, emailTo);
final MimeMessagePreparator preparator = new MimeMessagePreparator() {
......@@ -67,6 +71,7 @@ public class EMailServiceImpl implements EMailService {
message.setFrom(emailFrom);
message.setTo(emailTo);
message.setCc(emailCc);
message.setSubject(subject);
message.setText(text, true);
......
......@@ -67,7 +67,7 @@ public class EMailVerificationServiceImpl implements EMailVerificationService {
String mailSubject = article.getTitle();
String mailBody = MessageFormat.format(article.getBody(), baseUrl, verificationToken.getUuid(), user.getEmail(), verificationToken.getKey());
emailService.sendMail(user.getEmail(), user.getName(), mailSubject, mailBody);
emailService.sendMail(mailSubject, mailBody, user.getEmail());
}
@Override
......@@ -80,7 +80,7 @@ public class EMailVerificationServiceImpl implements EMailVerificationService {
String mailSubject = article.getTitle();
String mailBody = MessageFormat.format(article.getBody(), baseUrl, verificationToken.getUuid(), user.getEmail(), verificationToken.getKey());
emailService.sendMail(user.getEmail(), user.getName(), mailSubject, mailBody);
emailService.sendMail(mailSubject, mailBody, user.getEmail());
}
@Override
......
......@@ -137,7 +137,7 @@ public class RequestServiceImpl implements RequestService {
LOG.info(">>>" + mailBody);
// send to user
emailService.sendMail(request.getEmail(), null, mailSubject, mailBody);
emailService.sendMail(mailSubject, mailBody, request.getEmail());
return request;
}
......@@ -277,7 +277,9 @@ public class RequestServiceImpl implements RequestService {
recipient = StringUtils.defaultIfBlank(instMailToSetting.getValue(), null);
}
String[] emailCc = null;
if (recipient != null) {
emailCc = new String[] { requestsEmail };
// TODO If such user is registered, use to user's selected locale
} else {
LOG.info("Using default email to relay request for institute " + materialSubRequest.getInstCode());
......@@ -310,7 +312,7 @@ public class RequestServiceImpl implements RequestService {
LOG.info(">>>" + mailBody);
// send to recipient
emailService.sendMail(materialSubRequest.getInstEmail(), null, mailSubject, mailBody);
emailService.sendMail(mailSubject, mailBody, emailCc, materialSubRequest.getInstEmail());
}
@Override
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment