From 861986cc51212295494c529d8a8f522abe32f245 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 11 Nov 2016 10:13:15 +0300 Subject: ws: fix injection and reply quote --- juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java | 1 - juick-ws/src/main/java/com/juick/ws/XMPPConnection.java | 11 +++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'juick-ws/src/main/java') 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 5860426a..2ab3a94c 100644 --- a/juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java +++ b/juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java @@ -9,7 +9,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.HttpHeaders; import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.stereotype.Component; import org.springframework.web.socket.CloseStatus; import org.springframework.web.socket.WebSocketSession; import org.springframework.web.socket.handler.TextWebSocketHandler; diff --git a/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java b/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java index 8dffd388..9e793a44 100644 --- a/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java +++ b/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java @@ -2,6 +2,7 @@ package com.juick.ws; import com.juick.User; import com.juick.json.MessageSerializer; +import com.juick.server.MessagesQueries; import com.juick.server.SubscriptionsQueries; import com.juick.xmpp.JID; import com.juick.xmpp.Message; @@ -32,7 +33,7 @@ public class XMPPConnection implements Stream.StreamListener, Message.MessageLis private static final Logger logger = LoggerFactory.getLogger(XMPPConnection.class); @Inject - JdbcTemplate sql; + JdbcTemplate jdbc; ExecutorService service; Stream xmpp; String xmppPassword; @@ -85,7 +86,9 @@ public class XMPPConnection implements Stream.StreamListener, Message.MessageLis } else if (jmsg.getRID() == 0) { onJuickMessagePost(jmsg); } else { - onJuickMessageReply(jmsg); + // to get quote + com.juick.Message reply = MessagesQueries.getReply(jdbc, jmsg.getMID(), jmsg.getRID()); + onJuickMessageReply(reply); } } } @@ -108,7 +111,7 @@ public class XMPPConnection implements Stream.StreamListener, Message.MessageLis private void onJuickMessagePost(com.juick.Message jmsg) { String json = messageSerializer.serialize(jmsg).toString(); - List uids = SubscriptionsQueries.getSubscribedUsers(sql, jmsg.getUser().getUID(), jmsg.getMID()) + List uids = SubscriptionsQueries.getSubscribedUsers(jdbc, jmsg.getUser().getUID(), jmsg.getMID()) .stream().map(User::getUID).collect(Collectors.toList()); synchronized (wsHandler.clients) { wsHandler.clients.stream().filter(c -> @@ -138,7 +141,7 @@ public class XMPPConnection implements Stream.StreamListener, Message.MessageLis private void onJuickMessageReply(com.juick.Message jmsg) { String json = messageSerializer.serialize(jmsg).toString(); List threadUsers = - SubscriptionsQueries.getUsersSubscribedToComments(sql, jmsg.getMID(), jmsg.getUser().getUID()) + SubscriptionsQueries.getUsersSubscribedToComments(jdbc, jmsg.getMID(), jmsg.getUser().getUID()) .stream().map(User::getUID).collect(Collectors.toList()); synchronized (wsHandler.clients) { wsHandler.clients.stream().filter(c -> -- cgit v1.2.3