From cd1597d7fe462b54b18ac6886e0c308e11e7e4dc Mon Sep 17 00:00:00 2001 From: Michal Badin <xbadin@fi.muni.cz> Date: Mon, 8 May 2023 20:22:13 +0200 Subject: [PATCH] fix(Rejected-email): Added email template --- .../muni/pa165/exceptions/EmailException.java | 10 +++ .../pa165/service/NotificationService.java | 16 +--- .../resources/templates/rejected-email.html | 88 +++++++++++++++++++ 3 files changed, 100 insertions(+), 14 deletions(-) create mode 100644 notification/src/main/java/cz/muni/pa165/exceptions/EmailException.java create mode 100644 notification/src/main/resources/templates/rejected-email.html diff --git a/notification/src/main/java/cz/muni/pa165/exceptions/EmailException.java b/notification/src/main/java/cz/muni/pa165/exceptions/EmailException.java new file mode 100644 index 0000000..660b662 --- /dev/null +++ b/notification/src/main/java/cz/muni/pa165/exceptions/EmailException.java @@ -0,0 +1,10 @@ +package cz.muni.pa165.exceptions; + +/** + * @author Michal Badin + */ +public class EmailException extends RuntimeException { + public EmailException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/notification/src/main/java/cz/muni/pa165/service/NotificationService.java b/notification/src/main/java/cz/muni/pa165/service/NotificationService.java index c7f73c9..d9742fd 100644 --- a/notification/src/main/java/cz/muni/pa165/service/NotificationService.java +++ b/notification/src/main/java/cz/muni/pa165/service/NotificationService.java @@ -1,5 +1,6 @@ package cz.muni.pa165.service; +import cz.muni.pa165.exceptions.EmailException; import cz.muni.pa165.generated.model.*; import jakarta.mail.MessagingException; import jakarta.mail.internet.MimeMessage; @@ -75,19 +76,6 @@ public class NotificationService { htmlContent = templateEngine.process("accepted-email", ctx); } else { htmlContent = templateEngine.process("rejected-email", ctx); - htmlContent = "Dear " + getFullName(a) + ",\n" + - "\n" + - "I regret to inform you that your application for the Formula Driver position has been declined. While we appreciate your interest in the role, we have decided to pursue other candidates whose skills and experience more closely match our requirements.\n" + - "\n" + - "I want to personally thank you for taking the time to apply for the position and for your passion for motorsports. We would like to keep your resume on file in case any suitable openings arise in the future.\n" + - "\n" + - "If you have any questions or would like feedback on your application, please feel free to reach out to us.\n" + - "\n" + - "Thank you again for considering Formula Team Management, and we wish you all the best in your future endeavors.\n" + - "\n" + - "Best regards,\n" + - "\n" + - "Formula Team Management"; } return sendEmail(subject, htmlContent, applicationNotificationDto.getReceivers()); @@ -111,7 +99,7 @@ public class NotificationService { .subject(subject) .message(text); } catch (MessagingException e) { - throw new RuntimeException("Failed to send email", e); + throw new EmailException("Failed to send email", e); } } diff --git a/notification/src/main/resources/templates/rejected-email.html b/notification/src/main/resources/templates/rejected-email.html new file mode 100644 index 0000000..bded181 --- /dev/null +++ b/notification/src/main/resources/templates/rejected-email.html @@ -0,0 +1,88 @@ +<!DOCTYPE html> +<html xmlns:th="http://www.thymeleaf.org" lang="en"> +<head> + <meta charset="utf-8"> + <title>Application for Formula Driver Position</title> + <style> + body { + font-family: Arial, sans-serif; + margin: 0; + padding: 0; + background-color: #f6f6f6; + } + + .header { + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: center; + } + + .header-right { + margin-left: auto; + } + + .container { + max-width: 625px; + margin: 0 auto; + background-color: #fff; + padding: 20px; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); + position: relative; + } + + h1 { + font-size: 24px; + font-weight: bold; + margin: 0; + text-align: left; + } + + .date { + font-size: 14px; + font-weight: normal; + margin: 0; + } + + .location { + font-size: 14px; + font-weight: normal; + margin: 0; + } + + p { + font-size: 16px; + line-height: 1.5; + margin: 20px 0; + text-align: justify; + } + + .signature { + font-size: 14px; + font-weight: normal; + margin: 50px 0 0 0; + text-align: right; + } + </style> +</head> +<body> +<div class="container"> + <div class="header"> + <h1>Application for Formula Driver Position</h1> + <div class="header-right"> + <div class="date" th:text="${today}"></div> + <div class="location">Brno, Czech Republic</div> + </div> + </div> + + <p><b>Dear <span th:text="${fullName}"></span>,</b></p> + <p>I regret to inform you that your application for the Formula Driver position has been <b>Declined</b>. While we appreciate your interest in the role, we have decided to pursue other candidates whose skills and experience more closely match our requirements.</p> + <p>I want to personally thank you for taking the time to apply for the position and for your passion for motorsports. We would like to keep your resume on file in case any suitable openings arise in the future.</p> + <p>If you have any questions or would like feedback on your application, please feel free to reach out to us.</p> + <p>Thank you again for considering Formula Team Management, and we wish you all the best in your future endeavors.</p> + <p>Best regards, + <br>Formula Team Management</p> + <div class="signature">-- Formula Team Management</div> +</div> +</body> +</html> \ No newline at end of file -- GitLab