changeset 36:157eac0dee34

whitelist for mailing lists
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 08 Jul 2020 12:22:41 -0600
parents 5ea557eece1f
children 40e282462f2e
files src/nabble/view/web/more/ForumStart.java src/nabble/view/web/more/ForumStart.jtp src/nabble/view/web/more/MailingListRequest.java src/nabble/view/web/more/MailingListRequest.jtp
diffstat 4 files changed, 18 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/nabble/view/web/more/ForumStart.java	Tue Jul 07 09:57:53 2020 -0600
+++ b/src/nabble/view/web/more/ForumStart.java	Wed Jul 08 12:22:41 2020 -0600
@@ -185,7 +185,7 @@
 	}
 
 
-	private static final Set whitelist = (Set)Init.get("whitelist");
+	static final Set whitelist = (Set)Init.get("whitelist");
 
 	public static class Save extends HttpServlet {
 
--- a/src/nabble/view/web/more/ForumStart.jtp	Tue Jul 07 09:57:53 2020 -0600
+++ b/src/nabble/view/web/more/ForumStart.jtp	Wed Jul 08 12:22:41 2020 -0600
@@ -250,7 +250,7 @@
 	}
 
 
-	private static final Set whitelist = (Set)Init.get("whitelist");
+	static final Set whitelist = (Set)Init.get("whitelist");
 
 	public static class Save extends HttpServlet {
 
--- a/src/nabble/view/web/more/MailingListRequest.java	Tue Jul 07 09:57:53 2020 -0600
+++ b/src/nabble/view/web/more/MailingListRequest.java	Wed Jul 08 12:22:41 2020 -0600
@@ -33,9 +33,12 @@
 import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 public final class MailingListRequest extends HttpServlet implements UrlMappable, CanonicalUrl {
+	private static final Logger logger = LoggerFactory.getLogger(MailingListRequest.class);
 
 	private static final Pattern URL_PATTERN = Pattern.compile("/archive-your-mailing-list\\.html$");
 
@@ -201,6 +204,11 @@
 			}
 
 			if (errors.isEmpty()) {
+				if( ForumStart.whitelist!=null && !ForumStart.whitelist.contains(email) ) {
+					logger.info("ignoring "+email);
+					return;
+				}
+
 				DbDatabase db = Db.dbGlobal();
 				db.beginTransaction();
 				try {
--- a/src/nabble/view/web/more/MailingListRequest.jtp	Tue Jul 07 09:57:53 2020 -0600
+++ b/src/nabble/view/web/more/MailingListRequest.jtp	Wed Jul 08 12:22:41 2020 -0600
@@ -33,9 +33,12 @@
 import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 public final class MailingListRequest extends HttpServlet implements UrlMappable, CanonicalUrl {
+	private static final Logger logger = LoggerFactory.getLogger(MailingListRequest.class);
 
 	private static final Pattern URL_PATTERN = Pattern.compile("/archive-your-mailing-list\\.html$");
 
@@ -297,6 +300,11 @@
 			}
 
 			if (errors.isEmpty()) {
+				if( ForumStart.whitelist!=null && !ForumStart.whitelist.contains(email) ) {
+					logger.info("ignoring "+email);
+					return;
+				}
+
 				DbDatabase db = Db.dbGlobal();
 				db.beginTransaction();
 				try {