From aa6535627dca4682cd392f3a8ee66b722c0667c5 Mon Sep 17 00:00:00 2001 From: Fabian Emilius Date: Mon, 29 Jul 2024 21:07:23 +0200 Subject: [PATCH] Add mail templates configuration --- server/Dockerfile | 2 +- .../{mails => mail-templates}/application-acceptance.html | 0 .../application-created-chair.html | 0 .../application-created-student.html | 0 .../{mails => mail-templates}/application-rejection.html | 0 .../main/java/thesistrack/ls1/service/MailingService.java | 7 ++++--- server/src/main/resources/application.yml | 1 + 7 files changed, 6 insertions(+), 4 deletions(-) rename server/{mails => mail-templates}/application-acceptance.html (100%) rename server/{mails => mail-templates}/application-created-chair.html (100%) rename server/{mails => mail-templates}/application-created-student.html (100%) rename server/{mails => mail-templates}/application-rejection.html (100%) diff --git a/server/Dockerfile b/server/Dockerfile index 4207b326..cdda4d61 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -10,6 +10,6 @@ EXPOSE 8080 RUN mkdir /app COPY --from=build /home/gradle/src/build/libs/*.jar /app/server.jar -COPY --from=build /home/gradle/src/mails /app/mails +COPY ./mail-templates /default-mail-templates ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom","-jar","/app/server.jar"] diff --git a/server/mails/application-acceptance.html b/server/mail-templates/application-acceptance.html similarity index 100% rename from server/mails/application-acceptance.html rename to server/mail-templates/application-acceptance.html diff --git a/server/mails/application-created-chair.html b/server/mail-templates/application-created-chair.html similarity index 100% rename from server/mails/application-created-chair.html rename to server/mail-templates/application-created-chair.html diff --git a/server/mails/application-created-student.html b/server/mail-templates/application-created-student.html similarity index 100% rename from server/mails/application-created-student.html rename to server/mail-templates/application-created-student.html diff --git a/server/mails/application-rejection.html b/server/mail-templates/application-rejection.html similarity index 100% rename from server/mails/application-rejection.html rename to server/mail-templates/application-rejection.html diff --git a/server/src/main/java/thesistrack/ls1/service/MailingService.java b/server/src/main/java/thesistrack/ls1/service/MailingService.java index 8d0be37c..17ebe392 100644 --- a/server/src/main/java/thesistrack/ls1/service/MailingService.java +++ b/server/src/main/java/thesistrack/ls1/service/MailingService.java @@ -34,13 +34,14 @@ public class MailingService { private final String workspaceUrl; private final String sender; private final List chairMemberRecipientsList; - private final Path rootLocation; + private final Path mailTemplateLocation; @Autowired public MailingService( JavaMailSender javaMailSender, UploadService uploadService, @Value("${thesis-track.mail.enabled}") boolean enabled, + @Value("${thesis-track.mail.mail-template-location}") String mailTemplateLocation, @Value("${thesis-track.mail.sender}") String sender, @Value("${thesis-track.mail.chair-member-recipients}") String chairMemberRecipientsList, @Value("${thesis-track.mail.footer}") String mailFooter, @@ -53,7 +54,7 @@ public MailingService( this.sender = sender; this.workspaceUrl = workspaceUrl; this.mailFooter = mailFooter; - this.rootLocation = Paths.get("mails"); + this.mailTemplateLocation = Paths.get(mailTemplateLocation); if (chairMemberRecipientsList != null && !chairMemberRecipientsList.isEmpty()) { this.chairMemberRecipientsList = Arrays.asList(chairMemberRecipientsList.split(";")); @@ -172,7 +173,7 @@ public void sendApplicationRejectionEmail(Application application) throws Mailin } private String getMailTemplate(String name) throws MailingException { - Path filePath = rootLocation.resolve(name + ".html"); + Path filePath = mailTemplateLocation.resolve(name + ".html"); try { byte[] fileBytes = Files.readAllBytes(filePath); diff --git a/server/src/main/resources/application.yml b/server/src/main/resources/application.yml index 92351ea0..b61bd229 100644 --- a/server/src/main/resources/application.yml +++ b/server/src/main/resources/application.yml @@ -58,6 +58,7 @@ thesis-track: footer: ${MAIL_FOOTER:} workspace-url: ${MAIL_WORKSPACE_URL:https://slack.com} chair-member-recipients: ${MAIL_CHAIR_RECIPIENTS:} + mail-template-location: ${MAIL_TEMPLATE_FOLDER:/default-mail-templates} storage: upload-location: ${UPLOAD_FOLDER:uploads}