diff options
Diffstat (limited to 'juick-server/src/main/java/com/juick/server/EmailManager.java')
-rw-r--r-- | juick-server/src/main/java/com/juick/server/EmailManager.java | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/juick-server/src/main/java/com/juick/server/EmailManager.java b/juick-server/src/main/java/com/juick/server/EmailManager.java index b185de5c..2bea7060 100644 --- a/juick-server/src/main/java/com/juick/server/EmailManager.java +++ b/juick-server/src/main/java/com/juick/server/EmailManager.java @@ -1,6 +1,7 @@ package com.juick.server; import com.juick.Message; +import com.juick.User; import com.juick.server.component.MessageEvent; import com.juick.service.EmailService; import com.juick.service.MessagesService; @@ -22,6 +23,7 @@ import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeBodyPart; import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeMultipart; +import java.util.List; import java.util.Properties; import static com.juick.formatters.PlainTextFormatter.formatPost; @@ -36,14 +38,13 @@ public class EmailManager implements ApplicationListener<MessageEvent> { @Inject private EmailService emailService; @Inject - private SubscriptionService subscriptionService; - @Inject private MessagesService messagesService; @Inject private UserService userService; @Override public void onApplicationEvent(@Nonnull MessageEvent event) { Message msg = event.getMessage(); + List<User> subscribedUsers = event.getUsers(); if (MessageUtils.isPM(msg)) { String subject = String.format("Private message from %s", msg.getUser().getName()); emailService.getEmails(msg.getTo().getUid(), true).forEach(email -> { @@ -52,13 +53,12 @@ public class EmailManager implements ApplicationListener<MessageEvent> { } else if (MessageUtils.isReply(msg)) { Message originalMessage = messagesService.getMessage(msg.getMid()); String subject = String.format("New reply to %s", originalMessage.getUser().getName()); - subscriptionService.getUsersSubscribedToComments(originalMessage, msg) - .stream().filter(user -> !userService.isInBLAny(user.getUid(), msg.getUser().getUid())) + subscribedUsers.stream() .flatMap(user -> emailService.getEmails(user.getUid(), true).stream()) .forEach(email -> emailNotify(email, subject, msg)); } else { String subject = String.format("New message from %s", msg.getUser().getName()); - subscriptionService.getSubscribedUsers(msg.getUser().getUid(), msg.getMid()) + subscribedUsers .forEach(user -> emailService.getEmails(user.getUid(), true) .forEach(email -> emailNotify(email, subject, msg))); } |