diff options
author | James Moger <james.moger@gitblit.com> | 2014-02-28 13:49:09 -0500 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2014-02-28 13:49:09 -0500 |
commit | d7c5a62f95c06839bda044d4bed11117219ad1a7 (patch) | |
tree | 88ac9dd2e2a8b47a4ae634b1968c493670ed57bb /src/main/java/com/gitblit/authority | |
parent | 4be7d8cd93084a2be3cd85f1d51dcb21af67eccf (diff) | |
download | gitblit-d7c5a62f95c06839bda044d4bed11117219ad1a7.tar.gz gitblit-d7c5a62f95c06839bda044d4bed11117219ad1a7.zip |
Improve notification api by introducing the Mailing model
Diffstat (limited to 'src/main/java/com/gitblit/authority')
-rw-r--r-- | src/main/java/com/gitblit/authority/GitblitAuthority.java | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/src/main/java/com/gitblit/authority/GitblitAuthority.java b/src/main/java/com/gitblit/authority/GitblitAuthority.java index 51626e64..5f4a7e7f 100644 --- a/src/main/java/com/gitblit/authority/GitblitAuthority.java +++ b/src/main/java/com/gitblit/authority/GitblitAuthority.java @@ -43,7 +43,6 @@ import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate;
import java.text.MessageFormat;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
@@ -51,12 +50,7 @@ import java.util.HashMap; import java.util.List;
import java.util.Map;
-import javax.activation.DataHandler;
-import javax.activation.FileDataSource;
import javax.mail.Message;
-import javax.mail.Multipart;
-import javax.mail.internet.MimeBodyPart;
-import javax.mail.internet.MimeMultipart;
import javax.swing.ImageIcon;
import javax.swing.InputVerifier;
import javax.swing.JButton;
@@ -93,6 +87,7 @@ import com.gitblit.IUserService; import com.gitblit.Keys;
import com.gitblit.client.HeaderPanel;
import com.gitblit.client.Translation;
+import com.gitblit.models.Mailing;
import com.gitblit.models.UserModel;
import com.gitblit.service.MailService;
import com.gitblit.utils.ArrayUtils;
@@ -854,27 +849,17 @@ public class GitblitAuthority extends JFrame implements X509Log { // send email
try {
if (mail.isReady()) {
- Message message = mail.createMessage(Arrays.asList(user.emailAddress));
- message.setSubject("Your Gitblit client certificate for " + metadata.serverHostname);
-
- // body of email
+ Mailing mailing = Mailing.newPlain();
+ mailing.subject = "Your Gitblit client certificate for " + metadata.serverHostname;
+ mailing.setRecipients(user.emailAddress);
String body = X509Utils.processTemplate(new File(folder, X509Utils.CERTS + File.separator + "mail.tmpl"), metadata);
if (StringUtils.isEmpty(body)) {
body = MessageFormat.format("Hi {0}\n\nHere is your client certificate bundle.\nInside the zip file are installation instructions.", user.getDisplayName());
}
- Multipart mp = new MimeMultipart();
- MimeBodyPart messagePart = new MimeBodyPart();
- messagePart.setText(body);
- mp.addBodyPart(messagePart);
-
- // attach zip
- MimeBodyPart filePart = new MimeBodyPart();
- FileDataSource fds = new FileDataSource(zip);
- filePart.setDataHandler(new DataHandler(fds));
- filePart.setFileName(fds.getName());
- mp.addBodyPart(filePart);
-
- message.setContent(mp);
+ mailing.content = body;
+ mailing.addAttachment(zip);
+
+ Message message = mail.createMessage(mailing);
mail.sendNow(message);
return true;
|