bugfix: now loading value of hold_time column in List table
This commit is contained in:
@@ -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> T getNullable(ResultSet rs, String colName) throws SQLException {
|
||||
final T val = (T) rs.getObject(colName);
|
||||
return rs.wasNull() ? null : val;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -87,12 +88,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 {
|
||||
@@ -123,8 +125,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 {
|
||||
@@ -232,7 +234,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;
|
||||
}
|
||||
|
||||
@@ -563,6 +566,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;
|
||||
|
||||
@@ -125,7 +125,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) {
|
||||
|
||||
Reference in New Issue
Block a user