From 8be07ed6ae47389b8279e808f305eb1b9a905ed8 Mon Sep 17 00:00:00 2001 From: Stephan Richter Date: Fri, 15 Mar 2024 09:43:33 +0100 Subject: [PATCH] Weiterleitung von Gast-Mails an Moderatoren bei moderierten Listen implementiert. Behebt Issue #1 Signed-off-by: Stephan Richter --- .../srsoftware/widerhall/data/ListMember.java | 1 + .../widerhall/data/MailingList.java | 20 ++++++------------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/main/java/de/srsoftware/widerhall/data/ListMember.java b/src/main/java/de/srsoftware/widerhall/data/ListMember.java index 7d5f54e..a5eb99c 100644 --- a/src/main/java/de/srsoftware/widerhall/data/ListMember.java +++ b/src/main/java/de/srsoftware/widerhall/data/ListMember.java @@ -322,6 +322,7 @@ public class ListMember { * @throws SQLException */ public static ListMember load(MailingList list,User user) throws SQLException { + if (list == null || user == null) return null; var rs = Database .open() .select(TABLE_NAME) diff --git a/src/main/java/de/srsoftware/widerhall/data/MailingList.java b/src/main/java/de/srsoftware/widerhall/data/MailingList.java index 3ef8e24..8a6e9f6 100644 --- a/src/main/java/de/srsoftware/widerhall/data/MailingList.java +++ b/src/main/java/de/srsoftware/widerhall/data/MailingList.java @@ -432,30 +432,22 @@ public class MailingList implements MessageHandler, ProblemListener { var senderEmail = internetAddress.getAddress(); var user = User.load(senderEmail); - if (user == null) { // no subscription - if (this.isOpenForGuests()) { - forward(message,subscribers()); - } else { - retainMessage(message); - sentRetentionNotification(senderEmail); - - } - return; - } - var member = ListMember.load(this, user); if (member == null || member.isAwaiting()) { // no subscription if (this.isOpenForGuests()) { - forward(message,subscribers()); - } else { + forward(message, subscribers()); + } else if (this.isOpenForSubscribers()){ retainMessage(message); sentRetentionNotification(senderEmail); + } else { + // at this point, the message is from a non-member and the list + // is only open to moderators. → forward to moderators + forward(message, moderators()); } return; } // at this point the member is at least a subscriber! - if (member.isModerator() || this.isOpenForSubscribers()) { forward(message,subscribers()); } else {