working on mailing list options
This commit is contained in:
@@ -219,6 +219,7 @@ public class Rest extends HttpServlet {
|
||||
if (list == null) return Map.of(ERROR,t("Mailinglist {} unknown",list.email()));
|
||||
var map = new HashMap<>();
|
||||
if (list.hasState(MailingList.STATE_FORWARD_FROM)) map.put("forward_from",true);
|
||||
if (list.hasState(MailingList.STATE_FORWARD_ATTACHED)) map.put("forward_attached",true);
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import de.srsoftware.widerhall.Util;
|
||||
import de.srsoftware.widerhall.data.ListMember;
|
||||
import de.srsoftware.widerhall.data.MailingList;
|
||||
import de.srsoftware.widerhall.data.User;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -269,19 +270,37 @@ public class Web extends TemplateServlet {
|
||||
}
|
||||
|
||||
private String inspect(HttpServletRequest req, HttpServletResponse resp) {
|
||||
var o = req.getSession().getAttribute(USER);
|
||||
if (!(o instanceof User user)) {
|
||||
return redirectTo(LOGIN,resp);
|
||||
}
|
||||
var post = req.getParameterMap();
|
||||
var listEmail = req.getParameter(LIST);
|
||||
var list = MailingList.load(listEmail);
|
||||
if (list == null) return t("{} is does not denote a valid list",listEmail);
|
||||
if (!list.mayBeAlteredBy(user)) {
|
||||
var user = Util.getUser(req);
|
||||
if (user == null) return redirectTo(LOGIN,resp);
|
||||
|
||||
var data = new HashMap<String,Object>();
|
||||
var error = false;
|
||||
|
||||
var list = Util.getMailingList(req);
|
||||
if (list == null) {
|
||||
error = true;
|
||||
data.put(ERROR, t("No valid mailing list provided!"));
|
||||
} else data.put(LIST, list.email());
|
||||
|
||||
if (!error && !list.mayBeAlteredBy(user)) {
|
||||
error = true;
|
||||
data.put(ERROR,t("You are not allowed to alter this list!"));
|
||||
}
|
||||
LOG.debug("POST: {}",post);
|
||||
return null;
|
||||
|
||||
if (!error){
|
||||
var dummy = req.getParameterMap();
|
||||
try {
|
||||
list.forwardFrom(Util.getCheckbox(req, "forward_from"));
|
||||
list.forwardAttached(Util.getCheckbox(req, "forward_attached"));
|
||||
data.put(NOTES,t("Sucessfully updated MailingList!"));
|
||||
} catch (SQLException e){
|
||||
LOG.warn("Failed to update MailingList:",e);
|
||||
data.put(ERROR,t("Failed to update MailingList!"));
|
||||
}
|
||||
LOG.debug("params: {}",dummy);
|
||||
}
|
||||
|
||||
return loadTemplate(INSPECT,data,resp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user