diff --git a/pom.xml b/pom.xml
index 43115bf..358ed47 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
org.example
Widerhall
- 0.2.56
+ 0.2.57
diff --git a/src/main/java/de/srsoftware/widerhall/Util.java b/src/main/java/de/srsoftware/widerhall/Util.java
index 3f64f67..eaa48fc 100644
--- a/src/main/java/de/srsoftware/widerhall/Util.java
+++ b/src/main/java/de/srsoftware/widerhall/Util.java
@@ -16,6 +16,8 @@ import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
+import java.sql.ResultSet;
+import java.sql.SQLException;
import java.util.Map;
import java.util.stream.Collectors;
@@ -162,4 +164,9 @@ public class Util {
public static String dropEmail(String tx) {
return tx.replaceAll( "[.\\-\\w]+@[.\\-\\w]+", "[email_removed]");
}
+
+ public static T getNullable(ResultSet rs, String colName) throws SQLException {
+ final T val = (T) rs.getObject(colName);
+ return rs.wasNull() ? null : val;
+ }
}
diff --git a/src/main/java/de/srsoftware/widerhall/data/MailingList.java b/src/main/java/de/srsoftware/widerhall/data/MailingList.java
index 6f78d7a..7a41626 100644
--- a/src/main/java/de/srsoftware/widerhall/data/MailingList.java
+++ b/src/main/java/de/srsoftware/widerhall/data/MailingList.java
@@ -1,6 +1,7 @@
package de.srsoftware.widerhall.data;
import de.srsoftware.widerhall.Configuration;
+import de.srsoftware.widerhall.Util;
import de.srsoftware.widerhall.mail.ImapClient;
import de.srsoftware.widerhall.mail.MessageHandler;
import de.srsoftware.widerhall.mail.ProblemListener;
@@ -86,12 +87,13 @@ public class MailingList implements MessageHandler, ProblemListener {
* @param smtpPass
* @param state
*/
- public MailingList(String email, String name, String imapHost, int imapPort, String imapUser, String imapPass, String inbox, String smtpHost, int smtpPort, String smtpUser, String smtpPass, int state) {
+ public MailingList(String email, String name, String imapHost, int imapPort, String imapUser, String imapPass, String inbox, String smtpHost, int smtpPort, String smtpUser, String smtpPass, int state, Integer holdTime) {
this.email = email.toLowerCase();
this.name = name;
this.state = state;
this.smtp = new SmtpClient(smtpHost,smtpPort,smtpUser,smtpPass,email);
this.imap = new ImapClient(imapHost,imapPort,imapUser,imapPass,inbox,this);
+ this.holdTime = holdTime;
}
public MailingList archive(boolean enabled) throws SQLException {
@@ -122,8 +124,8 @@ public class MailingList implements MessageHandler, ProblemListener {
* @return
* @throws SQLException
*/
- public static MailingList create(String email, String name, String imapHost, int imapPort, String imapUser, String imapPass, String inbox, String smtpHost, int smtpPort, String smtpUser, String smtpPass) throws SQLException {
- return new MailingList(email, name, imapHost, imapPort, imapUser, imapPass, inbox, smtpHost, smtpPort, smtpUser, smtpPass, DEFAULT_STATE).save();
+ public static MailingList create(String email, String name, String imapHost, int imapPort, String imapUser, String imapPass, String inbox, String smtpHost, int smtpPort, String smtpUser, String smtpPass, Integer holdTime) throws SQLException {
+ return new MailingList(email, name, imapHost, imapPort, imapUser, imapPass, inbox, smtpHost, smtpPort, smtpUser, smtpPass, DEFAULT_STATE, holdTime).save();
}
public static void createHoldTimeColumn() throws SQLException {
@@ -231,7 +233,8 @@ public class MailingList implements MessageHandler, ProblemListener {
rs.getInt(SMTP_PORT),
rs.getString(SMTP_USER),
rs.getString(SMTP_PASS),
- rs.getInt(STATE)));
+ rs.getInt(STATE),
+ Util.getNullable(rs,HOLD_TIME)));
return ml;
}
@@ -562,6 +565,7 @@ public class MailingList implements MessageHandler, ProblemListener {
.set(SMTP_USER, smtp.username())
.set(SMTP_PASS, smtp.password())
.set(STATE, state)
+ .set(HOLD_TIME,holdTime)
.compile()
.run();
return this;
diff --git a/src/main/java/de/srsoftware/widerhall/web/Web.java b/src/main/java/de/srsoftware/widerhall/web/Web.java
index cb84a6e..2835f43 100644
--- a/src/main/java/de/srsoftware/widerhall/web/Web.java
+++ b/src/main/java/de/srsoftware/widerhall/web/Web.java
@@ -126,7 +126,7 @@ public class Web extends TemplateServlet {
}
try {
- var list = MailingList.create(email, name, imapHost, imapPort, imapUser, imapPass, inbox, smtpHost, smtpPort, smtpUser, smtpPass);
+ var list = MailingList.create(email, name, imapHost, imapPort, imapUser, imapPass, inbox, smtpHost, smtpPort, smtpUser, smtpPass, null);
ListMember.create(list, user, ListMember.STATE_OWNER);
return redirectTo(ADMIN, resp);
} catch (SQLException e) {