don't challenge the same sender twice
authoradam <adam@megacz.com>
Sun, 28 Jan 2007 01:00:40 +0000 (01:00 +0000)
committeradam <adam@megacz.com>
Sun, 28 Jan 2007 01:00:40 +0000 (01:00 +0000)
darcs-hash:20070128010040-5007d-159f4fc4b67a2dac1ab536b6ec2d70e6dba1f763.gz

src/org/ibex/mail/Whitelist.java

index 06724fe..1fe679e 100644 (file)
@@ -115,6 +115,7 @@ public class Whitelist {
     public synchronized void challenge(Message m) {
         try {
             Log.warn(Whitelist.class, "challenging message: " + m.summary());
+
             Address to = m.headers.get("reply-to")==null ? null : Address.parse(m.headers.get("reply-to"));
             if (to==null) to = m.from;
             if (to==null) to = m.envelopeFrom;
@@ -186,8 +187,16 @@ public class Whitelist {
                 "      http://www.templetons.com/brad/spam/crgood.html\n";
 
             Message challenge = Message.newMessage(new Fountain.StringFountain(message));
-            if (!SMTP.Outgoing.attempt(challenge))
-                throw new RuntimeException("attempted to send challenge but could not: " + m.summary());
+
+            PreparedStatement query = conn.prepareStatement("select email from pending where email=?");
+            query.setString(1, to.toString(false));
+            ResultSet rs = query.executeQuery();
+            if (rs.next()) {
+                Log.warn(this, "already challenged " + to.toString(false) + "; not challenging again.");
+            } else {
+                if (!SMTP.Outgoing.attempt(challenge))
+                    throw new RuntimeException("attempted to send challenge but could not: " + m.summary());
+            }
 
             PreparedStatement add = conn.prepareStatement("insert into pending values(?,?,?,?)");
             add.setString(1, messageid);