first version with working archive
This commit is contained in:
@@ -3,6 +3,7 @@ package de.srsoftware.widerhall.web;
|
||||
import de.srsoftware.widerhall.Util;
|
||||
import de.srsoftware.widerhall.data.ListMember;
|
||||
import de.srsoftware.widerhall.data.MailingList;
|
||||
import de.srsoftware.widerhall.data.Post;
|
||||
import de.srsoftware.widerhall.data.User;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
@@ -27,6 +28,7 @@ import static de.srsoftware.widerhall.Util.t;
|
||||
|
||||
public class Rest extends HttpServlet {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(Rest.class);
|
||||
private static final String LIST_ARCHIVE = "list/archive";
|
||||
private static final String LIST_DISABLE = "list/disable";
|
||||
private static final String LIST_EDITABLE = "list/editable";
|
||||
private static final String LIST_DETAIL = "list/detail";
|
||||
@@ -127,6 +129,9 @@ public class Rest extends HttpServlet {
|
||||
}
|
||||
} else {
|
||||
switch (path) {
|
||||
case LIST_ARCHIVE:
|
||||
json.put("archive",archive(req));
|
||||
break;
|
||||
case LIST_SUBSCRIBABLE:
|
||||
json.put("lists", MailingList.subscribable().stream().map(MailingList::minimalMap).toList());
|
||||
break;
|
||||
@@ -143,6 +148,19 @@ public class Rest extends HttpServlet {
|
||||
}
|
||||
}
|
||||
|
||||
private Map<Long, Object> archive(HttpServletRequest req) {
|
||||
var list = Util.getMailingList(req);
|
||||
if (list != null){
|
||||
try {
|
||||
return Post.find(list).stream().collect(Collectors.toMap(Post::timestamp,Post::safeMap));
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
LOG.debug("list: {}",list.email());
|
||||
return Map.of();
|
||||
}
|
||||
|
||||
public String handlePost(HttpServletRequest req, HttpServletResponse resp){
|
||||
|
||||
var user = Util.getUser(req);
|
||||
@@ -223,6 +241,7 @@ public class Rest extends HttpServlet {
|
||||
if (list.hasState(MailingList.STATE_HIDE_RECEIVERS)) map.put("hide_receivers",true);
|
||||
if (list.hasState(MailingList.STATE_REPLY_TO_LIST)) map.put("reply_to_list",true);
|
||||
if (list.hasState(MailingList.STATE_OPEN)) map.put("open",true);
|
||||
if (list.hasState(MailingList.STATE_PUBLIC_ARCHIVE)) map.put("archive",true);
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user