diff options
author | 2018-04-12 14:17:46 +0300 | |
---|---|---|
committer | 2018-04-12 14:17:46 +0300 | |
commit | 9e5a6b3f2f6907f18f22718bcb6f0ac7f79c95cd (patch) | |
tree | 06d4eab436f56607f324cd2c43808854c35a6dfc /juick-server/src/main/java/com/juick/server/EmailManager.java | |
parent | e24f7a7ce9eb765aa2f581defbe20433a647700d (diff) |
server: MessageEvent now have list of subscribers
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))); } |