Skip to content

Commit

Permalink
removed the wrapper arround simplemailmessage
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Gorzala committed Dec 27, 2023
1 parent 76b2f14 commit 266b3c1
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 24 deletions.
6 changes: 3 additions & 3 deletions src/main/java/net/dancier/dancer/contact/ContactService.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package net.dancier.dancer.contact;

import lombok.RequiredArgsConstructor;
import net.dancier.dancer.mail.model.DancierMailMessage;
import net.dancier.dancer.mail.service.MailCreationService;
import net.dancier.dancer.mail.service.MailEnqueueService;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.stereotype.Service;

import java.util.Map;
Expand All @@ -16,15 +16,15 @@ public class ContactService {
private final MailEnqueueService mailEnqueueService;

void send(ContactDto contactDto) {
DancierMailMessage mailToSender = mailCreationService.createDancierMessageFromTemplate(
SimpleMailMessage mailToSender = mailCreationService.createDancierMessageFromTemplate(
contactDto.getSender(),
"dev@dancier.net",
"Vielen Dank - Team Dancier",
MailCreationService.CONTACT_FORMULAR_FEEDBACK,
Map.of());

mailEnqueueService.enqueueMail(mailToSender);
DancierMailMessage mailToTeamDancier = mailCreationService.createDancierMessageFromTemplate(
SimpleMailMessage mailToTeamDancier = mailCreationService.createDancierMessageFromTemplate(
"dev@dancier.net",
contactDto.getSender(),
"Mail über das Kontakt formular",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package net.dancier.dancer.core.events;

import jakarta.transaction.Transactional;
import lombok.RequiredArgsConstructor;
import net.dancier.dancer.core.ScheduleMessagePort;
import net.dancier.dancer.mail.model.DancierMailMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.event.EventListener;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.stereotype.Component;

import java.net.URI;
Expand All @@ -22,7 +21,7 @@ public class ApplicationEventListener {
private final ScheduleMessagePort scheduleMessagePort;

@EventListener
public void handle(DancierMailMessage dancierMailMessage) {
public void handle(SimpleMailMessage dancierMailMessage) {
scheduleMessagePort.schedule(
dancierMailMessage,
UUID.randomUUID().toString(),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import jakarta.persistence.*;
import org.hibernate.type.SqlTypes;
import org.springframework.mail.SimpleMailMessage;

import java.io.Serializable;

Expand All @@ -23,5 +24,5 @@ public class OutgoingMail extends EntityWithUUID implements Serializable {

@JdbcTypeCode(SqlTypes.JSON)
@Basic(fetch = FetchType.EAGER)
private DancierMailMessage mail;
private SimpleMailMessage mail;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package net.dancier.dancer.mail.service;

import lombok.RequiredArgsConstructor;
import net.dancier.dancer.mail.model.DancierMailMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.mail.SimpleMailMessage;
Expand Down Expand Up @@ -32,14 +31,14 @@ public class MailCreationService {

private final TemplateEngine emailTemplateEngine;

public DancierMailMessage createDancierMessageFromTemplate(
public SimpleMailMessage createDancierMessageFromTemplate(
String to,
String from,
String subject,
String bodyTemplate,
Map<String, Object> context) {

final DancierMailMessage dancierMailMessage = new DancierMailMessage();
final SimpleMailMessage dancierMailMessage = new SimpleMailMessage();
dancierMailMessage.setFrom(from);
dancierMailMessage.setTo(to);
dancierMailMessage.setSubject(subject);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package net.dancier.dancer.mail.service;

import lombok.RequiredArgsConstructor;
import net.dancier.dancer.mail.model.DancierMailMessage;
import net.dancier.dancer.mail.repository.OutgoingMailRepository;
import net.dancier.dancer.mail.model.OutgoingMail;
import net.dancier.dancer.mail.model.OutgoingMailStatus;
Expand All @@ -21,7 +20,7 @@ public class MailEnqueueService {

private final ApplicationEventPublisher applicationEventPublisher;

public void enqueueMail(DancierMailMessage dancierMailMessage) {
public void enqueueMail(SimpleMailMessage dancierMailMessage) {
OutgoingMail outgoingMail = new OutgoingMail();
outgoingMail.setStatus(OutgoingMailStatus.QUEUED);
outgoingMail.setRetry(0);
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/net/dancier/dancer/mail/EndToEndMailTest.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package net.dancier.dancer.mail;

import net.dancier.dancer.AbstractPostgreSQLEnabledTest;
import net.dancier.dancer.mail.model.DancierMailMessage;
import net.dancier.dancer.mail.service.MailCreationService;
import net.dancier.dancer.mail.service.MailEnqueueService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.test.context.ActiveProfiles;

import jakarta.mail.MessagingException;
Expand All @@ -23,7 +23,7 @@ public class EndToEndMailTest extends AbstractPostgreSQLEnabledTest {
@Test
public void checkSending() throws MessagingException {
Map<String, Object> context = Map.of("name", "Marc", "validationLink", "http:/");
DancierMailMessage dancierMailMessage = mailCreationService.createDancierMessageFromTemplate(
SimpleMailMessage dancierMailMessage = mailCreationService.createDancierMessageFromTemplate(
"gorzala@gmx.de",
"no-reply@dancier.net",
"Bestätige Deine Email-Adresse",
Expand Down

0 comments on commit 266b3c1

Please sign in to comment.