fix betreft email voor invite pt 3
This commit is contained in:
@@ -32,6 +32,7 @@ public class AppointmentResource {
|
|||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@Path("/date")
|
@Path("/date")
|
||||||
public List<AppointmentDTO> getAppointmentsByDate(@QueryParam("start") String start) {
|
public List<AppointmentDTO> getAppointmentsByDate(@QueryParam("start") String start) {
|
||||||
|
System.out.println("Getting appointments from " + start);
|
||||||
String user = jwt.getClaim("username");
|
String user = jwt.getClaim("username");
|
||||||
return appointmentService.getAppointmentsByDate(start, user);
|
return appointmentService.getAppointmentsByDate(start, user);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -388,7 +388,7 @@ public class EmailService {
|
|||||||
"link", agendaLink
|
"link", agendaLink
|
||||||
);
|
);
|
||||||
|
|
||||||
String templatePath = "src/main/resources/templates/agenda-invite.html";
|
String templatePath = "templates/agenda-invite.html";
|
||||||
String htmlBody = emailTemplateService.loadTemplate(templatePath, replacements);
|
String htmlBody = emailTemplateService.loadTemplate(templatePath, replacements);
|
||||||
|
|
||||||
mailer.send(Mail.withHtml(recipient, "Uitnodiging om agenda te bekijken", htmlBody).setFrom("PayPoint <paypoint@melvanveen.nl>"));
|
mailer.send(Mail.withHtml(recipient, "Uitnodiging om agenda te bekijken", htmlBody).setFrom("PayPoint <paypoint@melvanveen.nl>"));
|
||||||
|
|||||||
@@ -3,23 +3,29 @@ package nl.veenm.paypoint.service;
|
|||||||
import jakarta.enterprise.context.ApplicationScoped;
|
import jakarta.enterprise.context.ApplicationScoped;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ApplicationScoped
|
@ApplicationScoped
|
||||||
public class EmailTemplateService {
|
public class EmailTemplateService {
|
||||||
|
|
||||||
public String loadTemplate(String templatePath, Map<String, String> replacements) {
|
public String loadTemplate(String templatePath, Map<String, String> replacements) {
|
||||||
try {
|
try (InputStream is = Thread.currentThread().getContextClassLoader()
|
||||||
String content = Files.readString(Path.of(templatePath), StandardCharsets.UTF_8);
|
.getResourceAsStream(templatePath)) {
|
||||||
|
|
||||||
for (Map.Entry<String, String> entry : replacements.entrySet()) {
|
if (is == null) {
|
||||||
content = content.replace("{{" + entry.getKey() + "}}", entry.getValue());
|
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) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException("Kon e-mailtemplate niet inladen: " + templatePath, e);
|
throw new RuntimeException("Kon e-mailtemplate niet inladen: " + templatePath, e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user