|
|
|
@ -39,6 +39,7 @@ public class MailingList implements MessageHandler {
@@ -39,6 +39,7 @@ public class MailingList implements MessageHandler {
|
|
|
|
|
private static final int STATE_ENABLED = 1; |
|
|
|
|
private static final int STATE_PUBLIC = 2; |
|
|
|
|
public static final int STATE_FORWARD_FROM = 4; |
|
|
|
|
public static final int STATE_FORWARD_ATTACHED = 8; |
|
|
|
|
private static final int VISIBLE = 1; |
|
|
|
|
private static final int HIDDEN = 0; |
|
|
|
|
private final String name; |
|
|
|
@ -131,8 +132,7 @@ public class MailingList implements MessageHandler {
@@ -131,8 +132,7 @@ public class MailingList implements MessageHandler {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void enable(boolean enable) throws SQLException { |
|
|
|
|
state = enable ? state | STATE_ENABLED : state ^ (state & STATE_ENABLED); |
|
|
|
|
Database.open().update(TABLE_NAME).set(STATE,state).where(EMAIL, email()).compile().run(); |
|
|
|
|
setFlag(STATE_ENABLED,enable); |
|
|
|
|
|
|
|
|
|
if (enable) { |
|
|
|
|
imap.start().addListener(this); |
|
|
|
@ -151,6 +151,15 @@ public class MailingList implements MessageHandler {
@@ -151,6 +151,15 @@ public class MailingList implements MessageHandler {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void forwardAttached(boolean forward) throws SQLException { |
|
|
|
|
setFlag(STATE_FORWARD_ATTACHED,forward); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void forwardFrom(boolean forward) throws SQLException { |
|
|
|
|
setFlag(STATE_FORWARD_FROM,forward); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Create a mailing list object from a ResultSet. |
|
|
|
|
* This is a cached method: if the ML has been loaded before, the already-loaded object will be returned. |
|
|
|
@ -182,8 +191,7 @@ public class MailingList implements MessageHandler {
@@ -182,8 +191,7 @@ public class MailingList implements MessageHandler {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void hide(boolean hide) throws SQLException { |
|
|
|
|
state = hide ? state ^ (state & STATE_PUBLIC) : state | STATE_PUBLIC; |
|
|
|
|
Database.open().update(TABLE_NAME).set(STATE,state).where(EMAIL, email()).compile().run(); |
|
|
|
|
setFlag(STATE_PUBLIC,!hide); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -362,6 +370,11 @@ public class MailingList implements MessageHandler {
@@ -362,6 +370,11 @@ public class MailingList implements MessageHandler {
|
|
|
|
|
smtp.login().send(email(),name(),user.email(),subject,text); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void 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(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Map<String,Integer> stateMap(){ |
|
|
|
|
var map = new HashMap<String,Integer>(); |
|
|
|
|
if (hasState(STATE_ENABLED)) map.put("enabled",VISIBLE); |
|
|
|
|