working on editing of list properties

This commit is contained in:
2022-04-16 11:45:19 +02:00
parent 3ef331db1a
commit 7b41ece15e
7 changed files with 61 additions and 16 deletions

View File

@@ -66,6 +66,12 @@ public class MailingList {
Database.open().query(sql.toString()).run();
}
public static void enable(String listEmail, boolean enable) throws SQLException {
// https://stackoverflow.com/questions/16440831/bitwise-xor-in-sqlite-bitwise-not-not-working-as-i-expect
String expression = enable ? "state = state | "+ENABLED : "state = (~(state & "+ENABLED+"))&(state|"+ENABLED+")";
Database.open().query("UPDATE " + TABLE_NAME + " SET "+expression).where(EMAIL, listEmail).run();
}
public static void hide(String listEmail, boolean hide) throws SQLException {
// https://stackoverflow.com/questions/16440831/bitwise-xor-in-sqlite-bitwise-not-not-working-as-i-expect
String expression = hide ? "state = (~(state & "+PUBLIC+"))&(state|"+PUBLIC+")" : ("state = state | "+PUBLIC);
@@ -119,7 +125,8 @@ public class MailingList {
public Map<String, Object> safeMap() {
var map = new HashMap<String,Object>();
map.put(EMAIL,email);
String[] parts = email.split("@", 2);
map.put(EMAIL,Map.of(PREFIX,parts[0],DOMAIN,parts[1]));
map.put(NAME, name);
if (imapHost != null) map.put(IMAP_HOST, imapHost);
if (imapPort != 0) map.put(IMAP_PORT, imapPort);