From c82a5fe807663d963843afcd00d9eeb892db8655 Mon Sep 17 00:00:00 2001 From: adam Date: Sun, 28 Jan 2007 01:00:40 +0000 Subject: [PATCH] don't challenge the same sender twice darcs-hash:20070128010040-5007d-159f4fc4b67a2dac1ab536b6ec2d70e6dba1f763.gz --- src/org/ibex/mail/Whitelist.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/org/ibex/mail/Whitelist.java b/src/org/ibex/mail/Whitelist.java index 06724fe..1fe679e 100644 --- a/src/org/ibex/mail/Whitelist.java +++ b/src/org/ibex/mail/Whitelist.java @@ -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); -- 1.7.10.4