aboutsummaryrefslogtreecommitdiff
path: root/juick-ws/src/main/java/com/juick
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2017-01-17 17:31:19 +0300
committerGravatar Vitaly Takmazov2017-01-17 17:31:19 +0300
commited993af2e0e95b9af8c949fc0a5c812e93731c14 (patch)
tree4f47adf8682b85c9a35ef54c000328d2596c63ca /juick-ws/src/main/java/com/juick
parent2ab4bed9aa1d3142e95f6861871097626e5958c1 (diff)
juick-server: messagePosted protocol event
Diffstat (limited to 'juick-ws/src/main/java/com/juick')
-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 {