Skip to content

Commit

Permalink
chore: rollback mail templating
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Eberl committed Dec 3, 2021
1 parent 6ecfc23 commit 2704a8c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

import de.caritas.cob.mailservice.api.exception.ExchangeMailServiceException;
import de.caritas.cob.mailservice.api.mailtemplate.TemplateImage;
import java.io.FileInputStream;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
Expand Down Expand Up @@ -138,12 +136,12 @@ private void addEmailAttachmentsIfNecessary(List<TemplateImage> templateImages,

int attachmentIndex = 0;
for (TemplateImage templateImage : templateImages) {
try (InputStream inputStream =
useCustomResourcesPath ? new FileInputStream(
customResourcePath + CUSTOM_TEMPLATE_IMAGE_DIR + templateImage.getFilename())
: getClass()
.getResourceAsStream(TEMPLATE_IMAGE_DIR + templateImage.getFilename())) {

try {
var inputStream =
useCustomResourcesPath ? getClass().getResourceAsStream(
customResourcePath + CUSTOM_TEMPLATE_IMAGE_DIR + templateImage.getFilename())
: getClass()
.getResourceAsStream(TEMPLATE_IMAGE_DIR + templateImage.getFilename());
msg.getAttachments().addFileAttachment(templateImage.getFilename(), inputStream);
msg.getAttachments().getItems().get(attachmentIndex).setIsInline(true);
msg.getAttachments().getItems().get(attachmentIndex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import de.caritas.cob.mailservice.api.exception.TemplateDescriptionServiceException;
import de.caritas.cob.mailservice.api.mailtemplate.TemplateDescription;
import java.io.FileInputStream;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Optional;
Expand Down Expand Up @@ -67,11 +65,10 @@ private TemplateDescription loadTemplateDescription(String templateName)
*/
private String loadTemplateDescriptionFile(String templateName)
throws TemplateDescriptionServiceException {
try (InputStream inputStream =
useCustomResourcesPath ? new FileInputStream(
customResourcePath + templateName.toLowerCase() + TEMPLATE_EXTENSION)
: TemplateDescriptionService.class
.getResourceAsStream(getTemplateFilename(templateName))) {
try {
var inputStream = useCustomResourcesPath ? TemplateDescriptionService.class
.getResourceAsStream(customResourcePath + templateName.toLowerCase() + TEMPLATE_EXTENSION)
: TemplateDescriptionService.class.getResourceAsStream(getTemplateFilename(templateName));
assert inputStream != null;
final List<String> fileLines = IOUtils
.readLines(inputStream, StandardCharsets.UTF_8.displayName());
Expand Down

0 comments on commit 2704a8c

Please sign in to comment.