fix betreft email voor invite pt 3
Some checks failed
Docker Image CI / build-and-push (push) Failing after 10m19s
Docker Image CI / deploy (push) Has been skipped
Docker Image CI / notify-failure (push) Successful in 12s

This commit is contained in:
2025-04-19 20:21:37 +02:00
parent 764f931a29
commit 99cd5f2e66
3 changed files with 15 additions and 8 deletions

View File

@@ -32,6 +32,7 @@ public class AppointmentResource {
@Produces(MediaType.APPLICATION_JSON)
@Path("/date")
public List<AppointmentDTO> getAppointmentsByDate(@QueryParam("start") String start) {
System.out.println("Getting appointments from " + start);
String user = jwt.getClaim("username");
return appointmentService.getAppointmentsByDate(start, user);
}

View File

@@ -388,7 +388,7 @@ public class EmailService {
"link", agendaLink
);
String templatePath = "src/main/resources/templates/agenda-invite.html";
String templatePath = "templates/agenda-invite.html";
String htmlBody = emailTemplateService.loadTemplate(templatePath, replacements);
mailer.send(Mail.withHtml(recipient, "Uitnodiging om agenda te bekijken", htmlBody).setFrom("PayPoint <paypoint@melvanveen.nl>"));

View File

@@ -3,23 +3,29 @@ package nl.veenm.paypoint.service;
import jakarta.enterprise.context.ApplicationScoped;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Map;
@ApplicationScoped
public class EmailTemplateService {
public String loadTemplate(String templatePath, Map<String, String> replacements) {
try {
String content = Files.readString(Path.of(templatePath), StandardCharsets.UTF_8);
try (InputStream is = Thread.currentThread().getContextClassLoader()
.getResourceAsStream(templatePath)) {
for (Map.Entry<String, String> entry : replacements.entrySet()) {
content = content.replace("{{" + entry.getKey() + "}}", entry.getValue());
if (is == null) {
throw new RuntimeException("Kon e-mailtemplate niet vinden!");
}
return content;
String template = new String(is.readAllBytes(), StandardCharsets.UTF_8);
for (Map.Entry<String, String> entry : replacements.entrySet()) {
template = template.replace("{{" + entry.getKey() + "}}", entry.getValue());
}
return template;
} catch (IOException e) {
throw new RuntimeException("Kon e-mailtemplate niet inladen: " + templatePath, e);
}