]> WPIA git - gigi.git/blobdiff - util-testing/org/cacert/gigi/pages/Manager.java
upd: make email sender address fixed.
[gigi.git] / util-testing / org / cacert / gigi / pages / Manager.java
index 2bc7bdea20d182dc50b1220a013bd0dcf728aea6..0cf8e12d6055f342d0f81582cdad8922b4470ebb 100644 (file)
@@ -142,8 +142,20 @@ public class Manager extends Page {
 
     public static class MailFetcher extends DelegateMailProvider {
 
+        Pattern[] toForward;
+
         public MailFetcher(Properties props) {
             super(props, props.getProperty("emailProvider.manager.target"));
+            String str = props.getProperty("emailProvider.manager.filter");
+            if (str == null) {
+                toForward = new Pattern[0];
+            } else {
+                String[] parts = str.split(" ");
+                toForward = new Pattern[parts.length];
+                for (int i = 0; i < parts.length; i++) {
+                    toForward[i] = Pattern.compile(parts[i]);
+                }
+            }
         }
 
         @Override
@@ -152,14 +164,19 @@ public class Manager extends Page {
         }
 
         @Override
-        public synchronized void sendMail(String to, String subject, String message, String from, String replyto, String toname, String fromname, String errorsto, boolean extra) throws IOException {
+        public synchronized void sendMail(String to, String subject, String message, String replyto, String toname, String fromname, String errorsto, boolean extra) throws IOException {
             HashMap<String, LinkedList<String>> mails = Manager.getInstance().emails;
             LinkedList<String> hismails = mails.get(to);
             if (hismails == null) {
                 mails.put(to, hismails = new LinkedList<>());
             }
             hismails.addFirst(subject + "\n" + message);
-            super.sendMail(to, subject, message, from, replyto, toname, fromname, errorsto, extra);
+            for (int i = 0; i < toForward.length; i++) {
+                if (toForward[i].matcher(to).matches()) {
+                    super.sendMail(to, subject, message, replyto, toname, fromname, errorsto, extra);
+                    return;
+                }
+            }
         }
 
     }