Allow splash to send contact emails
This commit is contained in:
parent
6d27abaca8
commit
d81d6e8568
|
@ -2,6 +2,7 @@ package eu.eudat.controllers;
|
||||||
|
|
||||||
import eu.eudat.logic.managers.ContactEmailManager;
|
import eu.eudat.logic.managers.ContactEmailManager;
|
||||||
import eu.eudat.models.data.ContactEmail.ContactEmailModel;
|
import eu.eudat.models.data.ContactEmail.ContactEmailModel;
|
||||||
|
import eu.eudat.models.data.ContactEmail.PublicContactEmailModel;
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.models.data.security.Principal;
|
import eu.eudat.models.data.security.Principal;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
|
@ -38,4 +39,18 @@ public class ContactEmail {
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.ERROR_MESSAGE).message(ex.getMessage()));
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.ERROR_MESSAGE).message(ex.getMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@RequestMapping(method = RequestMethod.POST, path = "public", consumes = "application/x-www-form-urlencoded", produces = "application/json")
|
||||||
|
public @ResponseBody
|
||||||
|
ResponseEntity sendContactEmailNoAuth(@ModelAttribute PublicContactEmailModel contactEmailModel) {
|
||||||
|
logger.info(contactEmailModel.toString());
|
||||||
|
try {
|
||||||
|
this.contactEmailManager.sendContactEmailNoAuth(contactEmailModel);
|
||||||
|
return ResponseEntity.status(HttpStatus.NO_CONTENT).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||||
|
} catch (Exception ex) {
|
||||||
|
logger.error(ex.getMessage(), ex);
|
||||||
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.ERROR_MESSAGE).message(ex.getMessage()));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.eudat.logic.managers;
|
||||||
import eu.eudat.data.entities.UserInfo;
|
import eu.eudat.data.entities.UserInfo;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.ContactEmail.ContactEmailModel;
|
import eu.eudat.models.data.ContactEmail.ContactEmailModel;
|
||||||
|
import eu.eudat.models.data.ContactEmail.PublicContactEmailModel;
|
||||||
import eu.eudat.models.data.mail.SimpleMail;
|
import eu.eudat.models.data.mail.SimpleMail;
|
||||||
import eu.eudat.models.data.security.Principal;
|
import eu.eudat.models.data.security.Principal;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
|
@ -35,6 +36,17 @@ public class ContactEmailManager {
|
||||||
apiContext.getUtilitiesService().getMailService().sendSimpleMail(mail);
|
apiContext.getUtilitiesService().getMailService().sendSimpleMail(mail);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void sendContactEmailNoAuth(PublicContactEmailModel contactEmailModel) throws MessagingException {
|
||||||
|
SimpleMail mail = new SimpleMail();
|
||||||
|
String enrichedMail = contactEmailModel.getMessage() + "\n\n" + "Send by user: " + contactEmailModel.getEmail() ;
|
||||||
|
mail.setSubject(contactEmailModel.getAffiliation());
|
||||||
|
mail.setTo(environment.getProperty("contact_email.mail"));
|
||||||
|
mail.setContent(enrichedMail);
|
||||||
|
mail.setFrom(contactEmailModel.getEmail());
|
||||||
|
|
||||||
|
apiContext.getUtilitiesService().getMailService().sendSimpleMail(mail);
|
||||||
|
}
|
||||||
|
|
||||||
public void emailValidation(ContactEmailModel contactEmailModel) throws Exception {
|
public void emailValidation(ContactEmailModel contactEmailModel) throws Exception {
|
||||||
if (contactEmailModel.getSubject() == null || contactEmailModel.getSubject().trim().isEmpty()) {
|
if (contactEmailModel.getSubject() == null || contactEmailModel.getSubject().trim().isEmpty()) {
|
||||||
throw new Exception("Subject is empty");
|
throw new Exception("Subject is empty");
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
package eu.eudat.models.data.ContactEmail;
|
||||||
|
|
||||||
|
public class PublicContactEmailModel {
|
||||||
|
|
||||||
|
private String fullName;
|
||||||
|
private String email;
|
||||||
|
private String affiliation;
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
public String getFullName() {
|
||||||
|
return fullName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFullName(String fullName) {
|
||||||
|
this.fullName = fullName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmail(String email) {
|
||||||
|
this.email = email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAffiliation() {
|
||||||
|
return affiliation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAffiliation(String affiliation) {
|
||||||
|
this.affiliation = affiliation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
}
|
|
@ -61,38 +61,39 @@
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="col ">
|
<div class="col ">
|
||||||
<div class="page-title">Contact</div>
|
<div class="page-title">Contact</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="main-contact">
|
<form class="form" method="POST" action="http://localhost:8081/api/contactEmail/public">
|
||||||
<div class="col page-subtitle">
|
<div class="main-contact">
|
||||||
<div>Contact us to learn more</div>
|
<div class="col page-subtitle">
|
||||||
</div>
|
<div>Contact us to learn more</div>
|
||||||
<div class="col required">
|
</div>
|
||||||
<div>* Required fields</div>
|
<div class="col required">
|
||||||
</div>
|
<div>* Required fields</div>
|
||||||
<form class="form">
|
</div>
|
||||||
<!-- Full Name -->
|
|
||||||
<div class="col d-flex flex-direction-row pb-2">
|
<!-- Full Name -->
|
||||||
<div class="form-title">Full name</div> <div class="required">*</div>
|
<div class="col d-flex flex-direction-row pb-2">
|
||||||
</div>
|
<div class="form-title">Full name</div> <div class="required">*</div>
|
||||||
<div class="col pb-4"><input type="text" id="fullName" placeholder="Type your full name"></div>
|
</div>
|
||||||
<!-- E-mail -->
|
<div class="col pb-4"><input type="text" id="fullName" name="fullName" placeholder="Type your full name"></div>
|
||||||
<div class="col d-flex flex-direction-row pb-2">
|
<!-- E-mail -->
|
||||||
<div class="form-title">E-mail</div> <div class="required">*</div>
|
<div class="col d-flex flex-direction-row pb-2">
|
||||||
</div>
|
<div class="form-title">E-mail</div> <div class="required">*</div>
|
||||||
<div class="col pb-4"><input type="email" id="email" placeholder="Type your E-mail"></div>
|
</div>
|
||||||
<!-- Affiliation -->
|
<div class="col pb-4"><input type="email" id="email" name="email" placeholder="Type your E-mail"></div>
|
||||||
<div class="col d-flex flex-direction-row pb-2">
|
<!-- Affiliation -->
|
||||||
<div class="form-title">Affiliation</div> <div class="required">*</div>
|
<div class="col d-flex flex-direction-row pb-2">
|
||||||
</div>
|
<div class="form-title">Affiliation</div> <div class="required">*</div>
|
||||||
<div class="col pb-4"><input type="email" id="email" placeholder="Type your E-mail"></div>
|
</div>
|
||||||
<!-- Message -->
|
<div class="col pb-4"><input type="email" id="affiliation" name="affiliation" placeholder="Type your E-mail"></div>
|
||||||
<div class="col d-flex flex-direction-row pb-2">
|
<!-- Message -->
|
||||||
<div class="form-title">Message</div> <div class="required">*</div>
|
<div class="col d-flex flex-direction-row pb-2">
|
||||||
</div>
|
<div class="form-title">Message</div> <div class="required">*</div>
|
||||||
<div class="col pb-4"><textarea name="message" placeholder="Type your message here..."></textarea>
|
</div>
|
||||||
</form>
|
<div class="col pb-4"><textarea name="message" id="message" placeholder="Type your message here..."></textarea>
|
||||||
</div>
|
</div>
|
||||||
<button type="button" class="normal-btn ml-3">Send</button>
|
<button type="submit" class="normal-btn ml-3">Send</button>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<!-- Footer-->
|
<!-- Footer-->
|
||||||
|
@ -143,4 +144,4 @@
|
||||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in New Issue