aboutsummaryrefslogtreecommitdiff
path: root/juick-api/src/main/java/com/juick/api/EmailManager.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-01-12 11:34:43 +0300
committerGravatar Vitaly Takmazov2018-01-12 11:34:43 +0300
commit40b392f1d63f6aaa8794beaff4c0432dd29f1858 (patch)
tree96bec459d88522124196d9d8ca92e677b48d2da8 /juick-api/src/main/java/com/juick/api/EmailManager.java
parent59d08c3fe59077238e7f7774be359a7966ed522c (diff)
refactoring and tests fixes
Diffstat (limited to 'juick-api/src/main/java/com/juick/api/EmailManager.java')
-rw-r--r--juick-api/src/main/java/com/juick/api/EmailManager.java16
1 files changed, 10 insertions, 6 deletions
diff --git a/juick-api/src/main/java/com/juick/api/EmailManager.java b/juick-api/src/main/java/com/juick/api/EmailManager.java
index 1c105ef9..c90e7b7a 100644
--- a/juick-api/src/main/java/com/juick/api/EmailManager.java
+++ b/juick-api/src/main/java/com/juick/api/EmailManager.java
@@ -13,6 +13,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
+import javax.annotation.Nonnull;
import javax.inject.Inject;
import javax.mail.MessagingException;
import javax.mail.Multipart;
@@ -29,17 +30,20 @@ import static com.juick.formatters.PlainTextFormatter.formatUrl;
@Component
public class EmailManager implements ApplicationListener<MessageEvent> {
+
+ public static final String MSGID_PATTERN = "\\.|@|<";
+
private static final Logger logger = LoggerFactory.getLogger(EmailManager.class);
@Inject
- EmailService emailService;
+ private EmailService emailService;
@Inject
- SubscriptionService subscriptionService;
+ private SubscriptionService subscriptionService;
@Inject
- MessagesService messagesService;
+ private MessagesService messagesService;
@Inject
- UserService userService;
+ private UserService userService;
@Override
- public void onApplicationEvent(MessageEvent event) {
+ public void onApplicationEvent(@Nonnull MessageEvent event) {
Message msg = event.getMessage();
if (msg.getRid() == 0) {
String subject = String.format("New message from %s", msg.getUser().getName());
@@ -55,7 +59,7 @@ public class EmailManager implements ApplicationListener<MessageEvent> {
}
}
- void emailNotify(String email, String subject, Message msg) {
+ private void emailNotify(String email, String subject, Message msg) {
Properties prop = System.getProperties();
prop.put("mail.smtp.starttls.enable", "true");
Session session = Session.getDefaultInstance(prop);