fixed message forwarding:

- messages to open lists are always accepted and sent to all subscribers
- messages to normal lists are accepted from subscribers and sent to all subscribers
- messages to moderated lists are accepted only from mods and sent to all subscribers
- messages to moderated lists are from non-mod subscribers are forwarded to the mods
- all other messages are retained
This commit is contained in:
2022-04-23 18:03:03 +02:00
parent cb3dcb54fd
commit 1ad9c7278e
3 changed files with 80 additions and 67 deletions

View File

@@ -94,10 +94,15 @@ public class Rest extends HttpServlet {
if (!allowed) return Map.of(ERROR,"You are not allowed to remove this list!");
try {
list.hide(true).enable(false).openForGuests(false).openForSubscribers(false);
for (ListMember member : list.members()) { // drop all list members except for owner
if (!member.isOwner()) member.unsubscribe();
}
} catch (SQLException e) {
list.members().forEach(listMember -> {
try {
listMember.unsubscribe();
} catch (SQLException e) {
throw new RuntimeException(e);
}
});
} catch (Exception e) {
LOG.debug("Disabling and hiding of {} failed",list.email(),e);
}
return Map.of(SUCCESS,t("List {} disabled, closed for subscribers and hidden. Members have been removed.",list.email()));
@@ -338,7 +343,6 @@ public class Rest extends HttpServlet {
if (!list.membersMayBeListedBy(user)) Map.of(ERROR,t("You are not allowed to list members of '{}'",list.email()));
try {
var members = list.members()
.stream()
.map(ListMember::safeMap)
.toList();
return Map.of(MEMBERS,members,LIST,list.minimalMap());