use of pl.pollub.cs.pentagoncafe.flare.component.email.HtmlEmail in project Flare-event-calendar by PollubCafe.
the class RegistrationServiceImpl method sendActivationEmail.
private void sendActivationEmail(Email email) {
try {
checkArgument(email instanceof HtmlEmail);
emailSender.send((HtmlEmail) email);
} catch (MessagingException e) {
e.printStackTrace();
throw new SendingActivationEmailFailException();
}
}
use of pl.pollub.cs.pentagoncafe.flare.component.email.HtmlEmail in project Flare-event-calendar by PollubCafe.
the class EmailBuilderImpl method buildEmailToEventAuthor.
@Override
public EmailBuilder buildEmailToEventAuthor(String messageContent, String subject) {
HtmlEmail instance = new HtmlEmail("PentagonCafe");
instance.setSubject(subject);
Context emailTemplateContext = new Context();
emailTemplateContext.setVariable("messageContent", messageContent);
String templateName = "messageToEventAuthor";
String htmlContent = templateEngine.process(templateName, emailTemplateContext);
instance.setHtmlContent(htmlContent);
this.instance = instance;
return this;
}
use of pl.pollub.cs.pentagoncafe.flare.component.email.HtmlEmail in project Flare-event-calendar by PollubCafe.
the class EmailBuilderImpl method buildActivationEmail.
@Override
public EmailBuilder buildActivationEmail(String activationToken) {
HtmlEmail instance = new HtmlEmail("from@no-spam.com");
instance.setSubject("Finish registration");
Context emailTemplateCtx = new Context();
String activationURL = messages.get("registration.activationURL") + activationToken;
emailTemplateCtx.setVariable("activationURL", activationURL);
String templateName = "finishRegistration";
String htmlContent = templateEngine.process(templateName, emailTemplateCtx);
instance.setHtmlContent(htmlContent);
this.instance = instance;
return this;
}
use of pl.pollub.cs.pentagoncafe.flare.component.email.HtmlEmail in project Flare-event-calendar by PollubCafe.
the class EmailBuilderImpl method buildResetPasswordEmail.
@Override
public EmailBuilder buildResetPasswordEmail(String generatedPassword) {
HtmlEmail instance = new HtmlEmail("from@no-spam.com");
instance.setSubject("Reset password");
Context emailTemplateCtx = new Context();
emailTemplateCtx.setVariable("generatedPassword", generatedPassword);
String templateName = "forgotPassword";
String htmlContent = templateEngine.process(templateName, emailTemplateCtx);
instance.setHtmlContent(htmlContent);
this.instance = instance;
return this;
}
use of pl.pollub.cs.pentagoncafe.flare.component.email.HtmlEmail in project Flare-event-calendar by PollubCafe.
the class EmailSenderServiceImpl method sendEmail.
@Override
public void sendEmail(EmailToEventAuthorReqDTO emailToEventAuthorReqDTO) {
Event event = eventRepository.findById(emailToEventAuthorReqDTO.getEventID()).orElseThrow(() -> new ObjectNotFoundException(Event.class, "id", emailToEventAuthorReqDTO.getEventID()));
User eventAuthor = event.getOrganizer();
String message = emailToEventAuthorReqDTO.getContent();
String subject = emailToEventAuthorReqDTO.getSubject();
Email email = emailBuilder.buildEmailToEventAuthor(message, subject).to(eventAuthor.getEmail());
try {
checkArgument(email instanceof HtmlEmail);
emailSender.send((HtmlEmail) email);
} catch (MessagingException e) {
e.printStackTrace();
throw new SendingEmailException("Email to author sending filed.");
}
}
Aggregations