|
|
|
@ -22,6 +22,7 @@ import java.util.stream.Stream;
@@ -22,6 +22,7 @@ import java.util.stream.Stream;
|
|
|
|
|
|
|
|
|
|
import static de.srsoftware.widerhall.Constants.*; |
|
|
|
|
import static de.srsoftware.widerhall.Util.t; |
|
|
|
|
import static de.srsoftware.widerhall.data.ListMember.*; |
|
|
|
|
import static de.srsoftware.widerhall.data.User.PERMISSION_ADMIN; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -268,7 +269,7 @@ public class MailingList implements MessageHandler, ProblemListener {
@@ -268,7 +269,7 @@ public class MailingList implements MessageHandler, ProblemListener {
|
|
|
|
|
if (user == null) return false; |
|
|
|
|
try { |
|
|
|
|
var member = ListMember.load(this,user); |
|
|
|
|
return member.hasState(ListMember.STATE_OWNER|ListMember.STATE_SUBSCRIBER); // owners may subscribe their own mailing lists
|
|
|
|
|
return member.hasState(STATE_OWNER|STATE_SUBSCRIBER); // owners may subscribe their own mailing lists
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
LOG.warn("Was not able to load ListMember:",e); |
|
|
|
|
return false; |
|
|
|
@ -283,6 +284,16 @@ public class MailingList implements MessageHandler, ProblemListener {
@@ -283,6 +284,16 @@ public class MailingList implements MessageHandler, ProblemListener {
|
|
|
|
|
return hasState(STATE_OPEN_FOR_GUESTS|STATE_OPEN_FOR_SUBSCRIBERS); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public boolean isOwnedBy(User user) { |
|
|
|
|
if (user == null) return false; |
|
|
|
|
try { |
|
|
|
|
if (ListMember.load(this,user).isOwner()) return true; |
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
LOG.debug("Error loading list member for ({}, {})",user.email(),email()); |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static List<MailingList> listActive() { |
|
|
|
|
try { |
|
|
|
|
var list = new ArrayList<MailingList>(); |
|
|
|
@ -505,10 +516,6 @@ public class MailingList implements MessageHandler, ProblemListener {
@@ -505,10 +516,6 @@ public class MailingList implements MessageHandler, ProblemListener {
|
|
|
|
|
return list; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Stream<ListMember> owners() throws SQLException { |
|
|
|
|
return members().filter(ListMember::isOwner); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public MailingList replyToList(boolean on) throws SQLException { |
|
|
|
|
return setFlag(STATE_REPLY_TO_LIST,on); |
|
|
|
|
} |
|
|
|
@ -678,7 +685,7 @@ public class MailingList implements MessageHandler, ProblemListener {
@@ -678,7 +685,7 @@ public class MailingList implements MessageHandler, ProblemListener {
|
|
|
|
|
* @throws MessagingException |
|
|
|
|
*/ |
|
|
|
|
public void requestSubscription(User user, boolean skipConfirmation, ST template) throws SQLException, MessagingException { |
|
|
|
|
var state = skipConfirmation ? ListMember.STATE_SUBSCRIBER : ListMember.STATE_AWAITING_CONFIRMATION; |
|
|
|
|
var state = skipConfirmation ? STATE_SUBSCRIBER : STATE_AWAITING_CONFIRMATION; |
|
|
|
|
var member = ListMember.create(this,user,state); |
|
|
|
|
if (skipConfirmation) return; |
|
|
|
|
try { |
|
|
|
@ -742,6 +749,32 @@ public class MailingList implements MessageHandler, ProblemListener {
@@ -742,6 +749,32 @@ public class MailingList implements MessageHandler, ProblemListener {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public String transfer(User owner, String newOwnerMail) { |
|
|
|
|
User newOwner; |
|
|
|
|
try { |
|
|
|
|
newOwner = User.load(newOwnerMail); |
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
return t("Failed to load user for address {}",newOwnerMail); |
|
|
|
|
} |
|
|
|
|
ListMember member; |
|
|
|
|
try { |
|
|
|
|
member = ListMember.load(this,newOwner); |
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
return t("{} is not a member of {}",newOwner); |
|
|
|
|
} |
|
|
|
|
try { |
|
|
|
|
member.setState(STATE_OWNER); |
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
return t("Failed to transfer list ownership to {}",newOwner); |
|
|
|
|
} |
|
|
|
|
try { |
|
|
|
|
ListMember.load(this,owner).setState(STATE_MODERATOR); |
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
return t("Failed to withdraw ownership from {}",owner); |
|
|
|
|
} |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void update(String name, String email, String imapHost, Integer imapPort, String imapUser, String imapPass, String inbox, String smtpHost, Integer smtpPort, String smtpUser, String smtpPass) throws SQLException { |
|
|
|
|
imap.stop(); |
|
|
|
|
Database.open() |
|
|
|
|