aboutsummaryrefslogtreecommitdiff
path: root/juick-ws/src/main/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'juick-ws/src/main/java/com')
-rw-r--r--juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java b/juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java
index 909933e4..23223c0e 100644
--- a/juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java
+++ b/juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java
@@ -1,9 +1,11 @@
package com.juick.ws;
+import com.juick.Message;
import com.juick.User;
import com.juick.server.protocol.JuickProtocol;
import com.juick.server.protocol.ProtocolListener;
import com.juick.service.MessagesService;
+import com.juick.service.SubscriptionService;
import com.juick.service.UserService;
import org.apache.commons.lang3.CharEncoding;
import org.apache.commons.lang3.StringUtils;
@@ -42,6 +44,8 @@ public class WebsocketComponent extends TextWebSocketHandler implements Protocol
@Inject
MessagesService messagesService;
@Inject
+ SubscriptionService subscriptionService;
+ @Inject
JuickProtocol protocol;
@PostConstruct
@@ -172,6 +176,13 @@ public class WebsocketComponent extends TextWebSocketHandler implements Protocol
notifyUser(from, to, String.format("@%s subscribed to your blog", from.getName()));
}
+ @Override
+ public void messagePosted(Message msg) {
+ subscriptionService.getSubscribedUsers(msg.getUser().getUid(), msg.getMid()).forEach(u -> {
+ notifyUser(msg.getUser(), u, msg.getText());
+ });
+ }
+
private void notifyUser(User from, User to, String body) {
getClients().stream().filter(s -> !s.legacy && s.visitor.equals(to)).forEach(s -> {
try {