From 988273abdddb8d3de3d6e43016310c7e94cf17a8 Mon Sep 17 00:00:00 2001 From: adam Date: Thu, 5 Jul 2007 01:34:33 +0000 Subject: [PATCH] reorganize Auto.java darcs-hash:20070705013433-5007d-3f9c76b82d2188597568230d8d6d7f61a4014911.gz --- src/org/ibex/mail/Auto.java | 78 ++++++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 34 deletions(-) diff --git a/src/org/ibex/mail/Auto.java b/src/org/ibex/mail/Auto.java index 0df2b46..a022d69 100644 --- a/src/org/ibex/mail/Auto.java +++ b/src/org/ibex/mail/Auto.java @@ -6,23 +6,51 @@ package org.ibex.mail; import java.io.*; import java.util.*; import org.ibex.js.*; -import org.ibex.mail.target.*; +import org.ibex.io.*; +import org.ibex.io.Fountain; // FIXME FIXME: rate limiting - // FIXME: DSN's: RFC 3464 ==> NOTIFY=NEVER // FIXME: MDN's: RFC 3798 -/** Implements RFC3834-compliant auto-generated messages+replies */ +// FIXME +// SHOULD NOT issue the same response to the same sender more +// than once within a period of several days, even though that +// sender may have sent multiple messages. A 7-day period is +// RECOMMENDED as a default. + +// Personal and Group responses whose purpose is to notify the +// sender of a message of a temporary absence of the recipient +// (e.g., "vacation" and "out of the office" notices) SHOULD +// NOT be issued unless a valid address for the recipient is +// explicitly included in a recipient (e.g., To, Cc, Bcc, +// Resent-To, Resent-Cc, or Resent- Bcc) field of the subject +// message. + +// FIXME: be sure to never, ever return large responses (> a few kb) + +/** Implements RFC3834-safe/compliant auto-generated messages+replies */ public class Auto { - /* - public Message autoGenerate() { - // same as other, but: - ret.headers.put("Auto-Submitted", "auto-generated"); + /** + * Compose an auto-generated message (not a reply) compliant with RFC3834. + * + * @param from + * personal: should be the recipient of the message, might guess from message, MUST be customizable
+ * service: should be a human, and description should describe the service + * @param includeAutoInSubject if true; the string "Auto: " is prepended to the subject + */ + public Message autoGenerate(Headers headers, Fountain body, Address autoFrom, Address autoTo, boolean includeAutoInSubject) { + return Message.newMessageFromHeadersAndBody(new Headers(headers, new String[] { + "Auto-Submitted", "auto-generated", + "Precedence", "bulk", + "Subject", (includeAutoInSubject ? "Auto: " : "")+headers.get("subject"), + "From", autoFrom.toString(true), + "Reply-To", autoFrom.toString(false) + }), + body, null, autoTo); } - */ /** * Compose an auto-generated reply compliant with RFC3834. @@ -52,32 +80,14 @@ public class Auto { for(String key : m.headers.getHeaderNames()) if (key.toLowerCase().startsWith("list-")) return null; - // SHOULD NOT issue the same response to the same sender more - // than once within a period of several days, even though that - // sender may have sent multiple messages. A 7-day period is - // RECOMMENDED as a default. - - // Personal and Group responses whose purpose is to notify the - // sender of a message of a temporary absence of the recipient - // (e.g., "vacation" and "out of the office" notices) SHOULD - // NOT be issued unless a valid address for the recipient is - // explicitly included in a recipient (e.g., To, Cc, Bcc, - // Resent-To, Resent-Cc, or Resent- Bcc) field of the subject - // message. - - throw new Error("FIXME"); - /* - Message ret = m.reply(fountain, null, false); - - ret.headers.put("Auto-Submitted", "auto-replied"); - ret.headers.put("Precedence", "bulk"); // or list - ret.headers.put("From", autoFrom); - ret.headers.put("Reply-To", autoFrom); - if (includeAutoInSubject) - ret.headers.put("Subject", "Auto: " + m.subject); - */ + return m.reply(new String[] { + "Auto-Submitted", "auto-replied", + "Precedence", "bulk", + "Subject", (includeAutoInSubject ? "Auto: " : "")+m.subject, + "From", autoFrom.toString(true), + "Reply-To", autoFrom.toString(false) + }, + fountain, null, false); } - // don't return large responses (> a few kb) - } -- 1.7.10.4