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 0000000000000000000000000000000000000000..660b6625f26ecfe10c3e86ac9e2364d65e1f7ec3 --- /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 c7f73c94fa5bd4db731b25a5c6ace21ed38d0ac5..d9742fda3d354365f3a9f687060dfb319c43726f 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 0000000000000000000000000000000000000000..bded181896be3cc83966a485054e8d1d5ef279e0 --- /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