From aef476e384a82825cfcd62ef9f04d65e71ae31e0 Mon Sep 17 00:00:00 2001 From: Stephan Richter Date: Wed, 4 May 2022 00:37:41 +0200 Subject: [PATCH 1/2] bugfix --- pom.xml | 2 +- src/main/java/de/srsoftware/widerhall/data/ListMember.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index e67519e..4378796 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ org.example Widerhall - 0.2.59 + 0.2.60 diff --git a/src/main/java/de/srsoftware/widerhall/data/ListMember.java b/src/main/java/de/srsoftware/widerhall/data/ListMember.java index 92003f3..7d5f54e 100644 --- a/src/main/java/de/srsoftware/widerhall/data/ListMember.java +++ b/src/main/java/de/srsoftware/widerhall/data/ListMember.java @@ -69,9 +69,9 @@ public class ListMember { } try { if (member == null) { - ListMember.create(list, moderator, ListMember.STATE_MODERATOR); + ListMember.create(list, moderator, STATE_MODERATOR); } else { - member.setState((member.state | STATE_MODERATOR) ^ STATE_AWAITING_CONFIRMATION); + member.setState(Util.unset(member.state|STATE_MODERATOR,STATE_AWAITING_CONFIRMATION)); } } catch (SQLException e) { LOG.warn("Failed to make {} a moderator of {}",moderator.email(),list.email(),e); @@ -212,7 +212,7 @@ public class ListMember { if (member == null) { ListMember.create(list, moderator, ListMember.STATE_SUBSCRIBER); } else { - member.setState(ListMember.STATE_SUBSCRIBER); + member.setState(Util.unset(member.state,STATE_MODERATOR)); } } catch (SQLException e) { LOG.warn("Failed to make {} a subscriber of {}",moderator.email(),list.email(),e); From 0fa9796294f976996b7c80243a564bdd4f08554d Mon Sep 17 00:00:00 2001 From: Stephan Richter Date: Wed, 4 May 2022 00:51:55 +0200 Subject: [PATCH 2/2] applied some sorting --- pom.xml | 2 +- src/main/java/de/srsoftware/widerhall/data/User.java | 1 + src/main/java/de/srsoftware/widerhall/web/Rest.java | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 4378796..5157743 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ org.example Widerhall - 0.2.60 + 0.2.61 diff --git a/src/main/java/de/srsoftware/widerhall/data/User.java b/src/main/java/de/srsoftware/widerhall/data/User.java index d2321d4..eae649e 100644 --- a/src/main/java/de/srsoftware/widerhall/data/User.java +++ b/src/main/java/de/srsoftware/widerhall/data/User.java @@ -175,6 +175,7 @@ public class User { if (emails != null) query.where(EMAIL,emails); var rs = query.compile().exec(); while (rs.next()) userList.add(User.from(rs)); + Collections.sort(userList,(u1,u2)->u1.name.compareTo(u2.name)); return userList; } diff --git a/src/main/java/de/srsoftware/widerhall/web/Rest.java b/src/main/java/de/srsoftware/widerhall/web/Rest.java index 1d35b1f..6d75c53 100644 --- a/src/main/java/de/srsoftware/widerhall/web/Rest.java +++ b/src/main/java/de/srsoftware/widerhall/web/Rest.java @@ -167,7 +167,7 @@ public class Rest extends HttpServlet { } break; case LIST_MODERATED: - json.put("lists", MailingList.moderatedBy(user).stream().map(MailingList::safeMap).toList()); + json.put("lists", MailingList.moderatedBy(user).stream().sorted((l1,l2)->l1.name().compareTo(l2.name())).map(MailingList::safeMap).toList()); break; case LIST_SUBSCRIBABLE: json.put("lists", MailingList.subscribable(user).stream().map(MailingList::minimalMap).toList()); @@ -348,6 +348,7 @@ 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() + .sorted((m1,m2)->m1.user().name().compareTo(m2.user().name())) .map(ListMember::safeMap) .toList(); return Map.of(MEMBERS,members,LIST,list.minimalMap());