Files
paypoint-backend/src/main/java/nl/veenm/paypoint/service/EmailTemplateService.java
veenm 99cd5f2e66
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
fix betreft email voor invite pt 3
2025-04-19 20:21:37 +02:00

35 lines
1.0 KiB
Java

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.util.Map;
@ApplicationScoped
public class EmailTemplateService {
public String loadTemplate(String templatePath, Map<String, String> replacements) {
try (InputStream is = Thread.currentThread().getContextClassLoader()
.getResourceAsStream(templatePath)) {
if (is == null) {
throw new RuntimeException("Kon e-mailtemplate niet vinden!");
}
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);
}
}
}