|
|
|
@ -42,6 +42,7 @@ public class MailingList implements MessageHandler {
@@ -42,6 +42,7 @@ public class MailingList implements MessageHandler {
|
|
|
|
|
public static final int STATE_FORWARD_ATTACHED = 8; |
|
|
|
|
public static final int STATE_HIDE_RECEIVERS = 16; |
|
|
|
|
public static final int STATE_REPLY_TO_LIST = 32; |
|
|
|
|
public static final int STATE_OPEN = 64; |
|
|
|
|
private static final int VISIBLE = 1; |
|
|
|
|
private static final int HIDDEN = 0; |
|
|
|
|
private static final int DEFAULT_STATE = STATE_PENDING|STATE_HIDE_RECEIVERS; |
|
|
|
@ -134,7 +135,7 @@ public class MailingList implements MessageHandler {
@@ -134,7 +135,7 @@ public class MailingList implements MessageHandler {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void enable(boolean enable) throws SQLException { |
|
|
|
|
public MailingList enable(boolean enable) throws SQLException { |
|
|
|
|
setFlag(STATE_ENABLED,enable); |
|
|
|
|
|
|
|
|
|
if (enable) { |
|
|
|
@ -142,6 +143,7 @@ public class MailingList implements MessageHandler {
@@ -142,6 +143,7 @@ public class MailingList implements MessageHandler {
|
|
|
|
|
} else { |
|
|
|
|
imap.stop(); |
|
|
|
|
} |
|
|
|
|
return this; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void forward(Message message) throws MessagingException { |
|
|
|
@ -153,7 +155,7 @@ public class MailingList implements MessageHandler {
@@ -153,7 +155,7 @@ public class MailingList implements MessageHandler {
|
|
|
|
|
.map(User::email) |
|
|
|
|
.toList(); |
|
|
|
|
var subject = message.getSubject(); |
|
|
|
|
// TODO: remove '(from …)' from subject
|
|
|
|
|
|
|
|
|
|
if (!subject.contains(stamp())) subject = stamp()+" "+subject; |
|
|
|
|
var replyTo = (newSender == null && hasState(STATE_REPLY_TO_LIST)) ? email() : null; |
|
|
|
|
smtp.forward(newSender,receivers,message,subject,hasState(STATE_FORWARD_ATTACHED),hasState(STATE_HIDE_RECEIVERS),replyTo); |
|
|
|
@ -162,12 +164,12 @@ public class MailingList implements MessageHandler {
@@ -162,12 +164,12 @@ public class MailingList implements MessageHandler {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void forwardAttached(boolean forward) throws SQLException { |
|
|
|
|
setFlag(STATE_FORWARD_ATTACHED,forward); |
|
|
|
|
public MailingList forwardAttached(boolean forward) throws SQLException { |
|
|
|
|
return setFlag(STATE_FORWARD_ATTACHED,forward); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void forwardFrom(boolean forward) throws SQLException { |
|
|
|
|
setFlag(STATE_FORWARD_FROM,forward); |
|
|
|
|
public MailingList forwardFrom(boolean forward) throws SQLException { |
|
|
|
|
return setFlag(STATE_FORWARD_FROM,forward); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -201,12 +203,12 @@ public class MailingList implements MessageHandler {
@@ -201,12 +203,12 @@ public class MailingList implements MessageHandler {
|
|
|
|
|
return (state & test) > 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void hide(boolean hide) throws SQLException { |
|
|
|
|
setFlag(STATE_PUBLIC,!hide); |
|
|
|
|
public MailingList hide(boolean hide) throws SQLException { |
|
|
|
|
return setFlag(STATE_PUBLIC,!hide); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void hideReceivers(boolean hide) throws SQLException { |
|
|
|
|
setFlag(STATE_HIDE_RECEIVERS,hide); |
|
|
|
|
public MailingList hideReceivers(boolean hide) throws SQLException { |
|
|
|
|
return setFlag(STATE_HIDE_RECEIVERS,hide); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -316,6 +318,10 @@ public class MailingList implements MessageHandler {
@@ -316,6 +318,10 @@ public class MailingList implements MessageHandler {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public MailingList open(boolean open) throws SQLException { |
|
|
|
|
return setFlag(STATE_OPEN,open); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* provide the set of mailing lists that are publicy open to subscriptions |
|
|
|
|
* @return |
|
|
|
@ -336,8 +342,8 @@ public class MailingList implements MessageHandler {
@@ -336,8 +342,8 @@ public class MailingList implements MessageHandler {
|
|
|
|
|
return list; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void replyToList(boolean on) throws SQLException { |
|
|
|
|
setFlag(STATE_REPLY_TO_LIST,on); |
|
|
|
|
public MailingList replyToList(boolean on) throws SQLException { |
|
|
|
|
return setFlag(STATE_REPLY_TO_LIST,on); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -399,9 +405,10 @@ public class MailingList implements MessageHandler {
@@ -399,9 +405,10 @@ public class MailingList implements MessageHandler {
|
|
|
|
|
smtp.login().send(email(),name(),user.email(),subject,text); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void setFlag(int flag, boolean on) throws SQLException { |
|
|
|
|
private MailingList setFlag(int flag, boolean on) throws SQLException { |
|
|
|
|
state = on ? state | flag : state ^ (state & flag); |
|
|
|
|
Database.open().update(TABLE_NAME).set(STATE,state).where(EMAIL, email()).compile().run(); |
|
|
|
|
return this; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Map<String,Integer> stateMap(){ |
|
|
|
|