Skip to content

Commit

Permalink
new email log and service improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
marioserrano09 committed Dec 7, 2023
1 parent 5012f2c commit c610992
Show file tree
Hide file tree
Showing 13 changed files with 339 additions and 51 deletions.
4 changes: 2 additions & 2 deletions sources/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
<parent>
<artifactId>tools.dynamia.modules.email.parent</artifactId>
<groupId>tools.dynamia.modules</groupId>
<version>3.0.1</version>
<version>3.0.2</version>
</parent>

<artifactId>tools.dynamia.modules.email</artifactId>
<name>DynamiaModules - Email</name>
<version>3.0.1</version>
<version>3.0.2</version>
<url>https://www.dynamiasoluciones.com</url>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@

package tools.dynamia.modules.email;

import tools.dynamia.domain.ValidationError;
import tools.dynamia.integration.Containers;
import tools.dynamia.integration.scheduling.SchedulerUtil;
import tools.dynamia.modules.email.domain.EmailAccount;
import tools.dynamia.modules.email.domain.EmailTemplate;
import tools.dynamia.modules.email.services.EmailService;

import java.io.File;
import java.io.Serializable;
import java.util.ArrayList;
Expand All @@ -27,13 +34,6 @@
import java.util.Map;
import java.util.Set;

import tools.dynamia.domain.ValidationError;
import tools.dynamia.integration.Containers;
import tools.dynamia.integration.scheduling.SchedulerUtil;
import tools.dynamia.modules.email.domain.EmailAccount;
import tools.dynamia.modules.email.domain.EmailTemplate;
import tools.dynamia.modules.email.services.EmailService;

/**
* Email message helper. Use this class to create a setup an email message
*
Expand Down Expand Up @@ -64,6 +64,9 @@ public class EmailMessage implements Serializable {
private boolean templateOptional;
private Long accountId;

private boolean notification;
private String notificationUuid;

public EmailMessage() {
}

Expand Down Expand Up @@ -263,4 +266,27 @@ public void setAccountId(Long accountId) {
this.accountId = accountId;
}

public boolean isNotification() {
return notification;
}

public void setNotification(boolean notification) {
this.notification = notification;
}

public String getNotificationUuid() {
return notificationUuid;
}

public void setNotificationUuid(String notificationUuid) {
this.notificationUuid = notificationUuid;
}

public Set<String> loadAllAddresses() {
Set<String> all = new HashSet<>();
all.addAll(getTos());
all.addAll(getCcs());
all.addAll(getBccs());
return all;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class EmailAccount extends SimpleEntitySaaS {
private boolean useTTLS;
private boolean loginRequired;
private boolean preferred;
private boolean notifications;
private String enconding;

private boolean smsEnabled;
Expand Down Expand Up @@ -198,4 +199,12 @@ public boolean isUseSSL() {
public void setUseSSL(boolean useSSL) {
this.useSSL = useSSL;
}

public boolean isNotifications() {
return notifications;
}

public void setNotifications(boolean notifications) {
this.notifications = notifications;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package tools.dynamia.modules.email.domain;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import tools.dynamia.modules.email.EmailMessage;
import tools.dynamia.modules.saas.jpa.BaseEntitySaaS;

@Entity
@Table(name = "email_log")
public class EmailMessageLog extends BaseEntitySaaS {

@Column(length = 1000)
private String subject;
@Column(length = 1000, name = "log_to")
private String to;
@Column(length = 1000)
private String additionalAddress;

@Column(name = "log_sended")
private boolean sended;
@Column(length = 1000, name = "log_result")
private String result;
private boolean notification;
private String notificationId;
@Column(name = "log_from")
private String from;

public EmailMessageLog() {
}

public EmailMessageLog(EmailMessage message) {
this.subject = message.getSubject();
this.to = message.getTo();
var otherAddress = message.loadAllAddresses();
if (!otherAddress.isEmpty()) {
this.additionalAddress = String.join(",", message.loadAllAddresses());
}
this.notification = message.isNotification();
this.notificationId = message.getNotificationUuid();
this.sended = message.isSended();
this.from = message.getMailAccount() != null ? message.getMailAccount().getFromAddress() : null;
setAccountId(message.getAccountId());
}

public String getSubject() {
return subject;
}

public void setSubject(String subject) {
this.subject = subject;
}

public String getTo() {
return to;
}

public void setTo(String to) {
this.to = to;
}

public String getAdditionalAddress() {
return additionalAddress;
}

public void setAdditionalAddress(String additionalAddress) {
this.additionalAddress = additionalAddress;
}


public boolean isSended() {
return sended;
}

public void setSended(boolean sended) {
this.sended = sended;
}

public String getResult() {
return result;
}

public void setResult(String result) {
this.result = result;
}

public boolean isNotification() {
return notification;
}

public void setNotification(boolean notification) {
this.notification = notification;
}

public String getNotificationId() {
return notificationId;
}

public void setNotificationId(String notificationId) {
this.notificationId = notificationId;
}

public String getFrom() {
return from;
}

public void setFrom(String from) {
this.from = from;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ public interface EmailService {
*/
EmailTemplate getTemplateByName(String name, boolean autocreate);

EmailTemplate getTemplateByName(String name, boolean autocreate, Long accountId);

/**
* Find email template by name
*
Expand Down
Loading

0 comments on commit c610992

Please sign in to comment.