Added Importance and Expiry-Days to sent emails
This adds the configuration options suggested in Issue 389: sendemail.importance = {high,low} sendemail.expiryDays = 0,1,2... The default action is not set and so no headers are generated. Updated documentation to define the new values. Change-Id: I8b8125481598161eace6979f89fc606bdb5cf8dd
This commit is contained in:
@@ -1562,6 +1562,25 @@ email from Gerrit.
|
||||
+
|
||||
By default, unset, permitting delivery to any email address.
|
||||
|
||||
[[sendemail.importance]]sendemail.importance::
|
||||
+
|
||||
If present, emails sent from Gerrit will have the given level
|
||||
of importance. Valid values include 'high' and 'low', which
|
||||
email clients will render in different ways.
|
||||
+
|
||||
By default, unset, so no Importance header is generated.
|
||||
|
||||
[[sendemail.expiryDays]]sendemail.expiryDays::
|
||||
+
|
||||
If present, emails sent from Gerrit will expire after the given
|
||||
number of days. This will add the Expiry-Date header and
|
||||
email clients may expire or expunge mails whose Expiry-Date
|
||||
header is in the past. This should be a positive non-zero
|
||||
number indicating how many days in the future the mails
|
||||
should expire.
|
||||
+
|
||||
By default, unset, so no Expiry-Date header is generated.
|
||||
|
||||
[[sshd]] Section sshd
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
@@ -28,8 +28,10 @@ import org.eclipse.jgit.lib.Config;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
@@ -51,6 +53,8 @@ public class SmtpEmailSender implements EmailSender {
|
||||
private Encryption smtpEncryption;
|
||||
private boolean sslVerify;
|
||||
private Set<String> allowrcpt;
|
||||
private String importance;
|
||||
private int expiryDays;
|
||||
|
||||
@Inject
|
||||
SmtpEmailSender(@GerritServerConfig final Config cfg) {
|
||||
@@ -88,6 +92,8 @@ public class SmtpEmailSender implements EmailSender {
|
||||
rcpt.add(addr);
|
||||
}
|
||||
allowrcpt = Collections.unmodifiableSet(rcpt);
|
||||
importance = cfg.getString("sendemail", null, "importance");
|
||||
expiryDays = cfg.getInt("sendemail", null, "expiryDays", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -132,6 +138,15 @@ public class SmtpEmailSender implements EmailSender {
|
||||
setMissingHeader(hdrs, "Content-Transfer-Encoding", "8bit");
|
||||
setMissingHeader(hdrs, "Content-Disposition", "inline");
|
||||
setMissingHeader(hdrs, "User-Agent", "Gerrit/" + Version.getVersion());
|
||||
if(importance != null) {
|
||||
setMissingHeader(hdrs, "Importance", importance);
|
||||
}
|
||||
if(expiryDays > 0) {
|
||||
Date expiry = new Date(System.currentTimeMillis() +
|
||||
expiryDays * 24 * 60 * 60 * 1000 );
|
||||
setMissingHeader(hdrs, "Expiry-Date",
|
||||
new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z").format(expiry));
|
||||
}
|
||||
|
||||
try {
|
||||
final SMTPClient client = open();
|
||||
|
Reference in New Issue
Block a user