working on confirmed subscription
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package de.srsoftware.widerhall.data;
|
||||
|
||||
import de.srsoftware.widerhall.Util;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -19,23 +20,27 @@ public class ListMember {
|
||||
public static final String TABLE_NAME = "ListMembers";
|
||||
public static final int STATE_OWNER = 1;
|
||||
public static final int STATE_SUBSCRIBER = 2;
|
||||
public static final int STATE_UNCONFIRMED = 4;
|
||||
public static final int STATE_AWAITING_CONFIRMATION = 4;
|
||||
private static final String LIST_EMAIL = "list_email";
|
||||
private static final String USER_EMAIL = "user_email";
|
||||
private static final String STATE = "state";
|
||||
private static final String TOKEN = "token";
|
||||
private final String listEmail;
|
||||
private final String userEmail;
|
||||
private final String listEmail,token,userEmail;
|
||||
private final int state;
|
||||
|
||||
public ListMember(String listEmail, String userEmail, int state){
|
||||
public ListMember(String listEmail, String userEmail, int state, String token){
|
||||
this.listEmail = listEmail;
|
||||
this.userEmail = userEmail;
|
||||
this.state = state;
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public static ListMember create(MailingList list, User user, int state) throws SQLException {
|
||||
return new ListMember(list.email(),user.email(),state).save();
|
||||
String token = null;
|
||||
if ((state & STATE_AWAITING_CONFIRMATION) > 0){
|
||||
token = Util.sha256(String.join("/",list.email(),user.email(),user.salt()));
|
||||
}
|
||||
return new ListMember(list.email(),user.email(),state,token).save();
|
||||
}
|
||||
|
||||
public static void createTable() throws SQLException {
|
||||
@@ -94,6 +99,10 @@ public class ListMember {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String token() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public static void unsubscribe(MailingList list, User user) throws SQLException {
|
||||
var db = Database.open();
|
||||
var rs = db.select(TABLE_NAME)
|
||||
@@ -116,4 +125,5 @@ public class ListMember {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user