|
|
@ -178,17 +178,14 @@ public class Web extends TemplateServlet { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private String handleGet(HttpServletRequest req, HttpServletResponse resp) { |
|
|
|
private String handleGet(HttpServletRequest req, HttpServletResponse resp) { |
|
|
|
var path = req.getPathInfo(); |
|
|
|
var path = Util.getPath(req); |
|
|
|
if (path == null) return redirectTo(INDEX,resp); |
|
|
|
var user = Util.getUser(req); |
|
|
|
var o = req.getSession().getAttribute("user"); |
|
|
|
|
|
|
|
User user = o instanceof User ? (User) o : null; |
|
|
|
|
|
|
|
var data = new HashMap<String,Object>(); |
|
|
|
var data = new HashMap<String,Object>(); |
|
|
|
|
|
|
|
var list = Util.getMailingList(req); |
|
|
|
|
|
|
|
|
|
|
|
if (user != null) data.put(USER,user.safeMap()); |
|
|
|
if (user != null) data.put(USER,user.safeMap()); |
|
|
|
path = path.equals("/") ? INDEX : path.substring(1); |
|
|
|
|
|
|
|
String notes = null; |
|
|
|
|
|
|
|
var listEmail = req.getParameter(LIST); |
|
|
|
|
|
|
|
var list = MailingList.load(listEmail); |
|
|
|
|
|
|
|
if (list != null) data.put(LIST,list.minimalMap()); |
|
|
|
if (list != null) data.put(LIST,list.minimalMap()); |
|
|
|
|
|
|
|
String notes = null; |
|
|
|
switch (path){ |
|
|
|
switch (path){ |
|
|
|
case ARCHIVE: |
|
|
|
case ARCHIVE: |
|
|
|
return archive(req,resp); |
|
|
|
return archive(req,resp); |
|
|
@ -206,7 +203,7 @@ public class Web extends TemplateServlet { |
|
|
|
return loadTemplate(path,data,resp); |
|
|
|
return loadTemplate(path,data,resp); |
|
|
|
case SUBSCRIBE: |
|
|
|
case SUBSCRIBE: |
|
|
|
if (list.isOpenFor(user)) { |
|
|
|
if (list.isOpenFor(user)) { |
|
|
|
data.put(LIST,listEmail); |
|
|
|
data.put(LIST,list.email()); |
|
|
|
return loadTemplate(path, data, resp); |
|
|
|
return loadTemplate(path, data, resp); |
|
|
|
} |
|
|
|
} |
|
|
|
return t("You are not allowed to subscribe to '{}'!",list.email()); |
|
|
|
return t("You are not allowed to subscribe to '{}'!",list.email()); |
|
|
@ -258,9 +255,7 @@ public class Web extends TemplateServlet { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private String handlePost(HttpServletRequest req, HttpServletResponse resp) { |
|
|
|
private String handlePost(HttpServletRequest req, HttpServletResponse resp) { |
|
|
|
final var user = Util.getUser(req); |
|
|
|
|
|
|
|
final var path = Util.getPath(req); |
|
|
|
final var path = Util.getPath(req); |
|
|
|
final var list = Util.getMailingList(req); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (path){ |
|
|
|
switch (path){ |
|
|
|
case ADD_LIST: |
|
|
|
case ADD_LIST: |
|
|
@ -382,14 +377,13 @@ public class Web extends TemplateServlet { |
|
|
|
var name = req.getParameter(NAME); |
|
|
|
var name = req.getParameter(NAME); |
|
|
|
var email = req.getParameter(EMAIL); |
|
|
|
var email = req.getParameter(EMAIL); |
|
|
|
var pass = req.getParameter(PASSWORD); |
|
|
|
var pass = req.getParameter(PASSWORD); |
|
|
|
var listEmail = req.getParameter(LIST); |
|
|
|
var list = Util.getMailingList(req); |
|
|
|
var data = new HashMap<String,Object>(); |
|
|
|
var data = new HashMap<String,Object>(); |
|
|
|
data.put(NAME,name); |
|
|
|
data.put(NAME,name); |
|
|
|
data.put(EMAIL,email); |
|
|
|
data.put(EMAIL,email); |
|
|
|
data.put(LIST,listEmail); |
|
|
|
if (list != null) data.put(LIST,list.email()); |
|
|
|
var skipConfirmation = false; |
|
|
|
var skipConfirmation = false; |
|
|
|
|
|
|
|
|
|
|
|
var list = MailingList.load(listEmail); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (list == null){ |
|
|
|
if (list == null){ |
|
|
|
data.put(ERROR,"No list provided by form data!"); |
|
|
|
data.put(ERROR,"No list provided by form data!"); |
|
|
@ -454,24 +448,19 @@ public class Web extends TemplateServlet { |
|
|
|
var data = new HashMap<String,Object>(); |
|
|
|
var data = new HashMap<String,Object>(); |
|
|
|
var user = getSessionUser(req); |
|
|
|
var user = getSessionUser(req); |
|
|
|
var email = req.getParameter(EMAIL); |
|
|
|
var email = req.getParameter(EMAIL); |
|
|
|
var pass = req.getParameter(PASSWORD); |
|
|
|
var list = Util.getMailingList(req); |
|
|
|
var listEmail = req.getParameter(LIST); |
|
|
|
|
|
|
|
data.put(EMAIL,email); |
|
|
|
data.put(EMAIL,email); |
|
|
|
data.put(LIST,listEmail); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var list = MailingList.load(listEmail); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (user != null) data.put(USER,user.safeMap()); |
|
|
|
if (user != null) data.put(USER,user.safeMap()); |
|
|
|
if (list == null){ |
|
|
|
if (list == null){ |
|
|
|
data.put(ERROR,"No list provided by form data!"); |
|
|
|
data.put(ERROR,"No list provided by form data!"); |
|
|
|
return loadTemplate(UNSUBSCRIBE,data,resp); |
|
|
|
return loadTemplate(UNSUBSCRIBE,data,resp); |
|
|
|
|
|
|
|
} else data.put(LIST,list.email()); |
|
|
|
} |
|
|
|
|
|
|
|
if (user == null) { |
|
|
|
if (user == null) { |
|
|
|
if (email == null || email.isBlank()) { |
|
|
|
if (email == null || email.isBlank()) { |
|
|
|
data.put(ERROR, "Email is required for list un-subscription!"); |
|
|
|
data.put(ERROR, "Email is required for list un-subscription!"); |
|
|
|
return loadTemplate(UNSUBSCRIBE, data, resp); |
|
|
|
return loadTemplate(UNSUBSCRIBE, data, resp); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var pass = req.getParameter(PASSWORD); |
|
|
|
if (pass != null && pass.isBlank()) pass = null; |
|
|
|
if (pass != null && pass.isBlank()) pass = null; |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|