use of org.commonmark.renderer.text.TextContentRenderer in project lavagna by digitalfondue.
the class MailTicketService method sendEmail.
private void sendEmail(String to, String name, Card createdCard, Board board, ProjectMailTicketConfig config, ProjectMailTicket ticketConfig) {
String cardId = board.getShortName() + "-" + createdCard.getSequence();
String subjectTemplate = "" + (ticketConfig.getNotificationOverride() ? ticketConfig.getSubject() : config.getSubject());
String bodyTemplate = "" + (ticketConfig.getNotificationOverride() ? ticketConfig.getBody() : config.getBody());
String subject = subjectTemplate.replaceAll("\\{\\{card}}", cardId);
String body = bodyTemplate.replaceAll("\\{\\{card}}", cardId).replaceAll("\\{\\{name}}", name != null ? name : to);
Parser parser = Parser.builder().build();
Node document = parser.parse(body);
HtmlRenderer htmlRenderer = HtmlRenderer.builder().build();
TextContentRenderer textRendered = TextContentRenderer.builder().build();
String htmlText = htmlRenderer.render(document);
String plainText = textRendered.render(document);
ProjectMailTicketConfigData configData = config.getConfig();
MailConfig mailConfig = new MailConfig(configData.getOutboundServer(), configData.getOutboundPort(), configData.getOutboundProtocol(), configData.getOutboundUser(), configData.getOutboundPassword(), ticketConfig.getSendByAlias() ? ticketConfig.getAlias() : configData.getOutboundAddress(), configData.getOutboundProperties());
mailConfig.send(to, subject, plainText, htmlText);
}
Aggregations