aboutsummaryrefslogtreecommitdiff
path: root/juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java
diff options
context:
space:
mode:
Diffstat (limited to 'juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java')
-rw-r--r--juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java22
1 files changed, 9 insertions, 13 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 9704b463..831d16f1 100644
--- a/juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java
+++ b/juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java
@@ -1,19 +1,18 @@
package com.juick.ws;
import com.juick.User;
-import com.juick.server.MessagesQueries;
-import com.juick.server.UserQueries;
+import com.juick.service.MessagesService;
+import com.juick.service.UserService;
import org.apache.http.NameValuePair;
import org.apache.http.client.utils.URLEncodedUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpHeaders;
-import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.util.Assert;
import org.springframework.web.socket.CloseStatus;
import org.springframework.web.socket.WebSocketSession;
import org.springframework.web.socket.handler.TextWebSocketHandler;
+import javax.inject.Inject;
import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
@@ -26,15 +25,12 @@ import java.util.List;
public class WebsocketComponent extends TextWebSocketHandler {
private static final Logger logger = LoggerFactory.getLogger(WebsocketComponent.class);
- private JdbcTemplate jdbc;
-
private final List<SocketSubscribed> clients = Collections.synchronizedList(new ArrayList<SocketSubscribed>());
-
- public WebsocketComponent(JdbcTemplate jdbc) {
- Assert.notNull(jdbc);
- this.jdbc = jdbc;
- }
+ @Inject
+ UserService userService;
+ @Inject
+ MessagesService messagesService;
@Override
public void afterConnectionEstablished(WebSocketSession session) throws Exception {
@@ -53,7 +49,7 @@ public class WebsocketComponent extends TextWebSocketHandler {
if (param.getName().equals("hash")) {
String hash = param.getValue();
if (hash.length() == 16) {
- visitor = UserQueries.getUserByHash(jdbc, hash);
+ visitor = userService.getUserByHash(hash);
} else {
try {
logger.info(String.format("wrong hash for %d from %s", visitor.getUid(), hXRealIP));
@@ -86,7 +82,7 @@ public class WebsocketComponent extends TextWebSocketHandler {
} catch (Exception e) {
}
if (MID > 0) {
- if (MessagesQueries.canViewThread(jdbc, MID, visitor.getUid())) {
+ if (messagesService.canViewThread(MID, visitor.getUid())) {
logger.info(String.format("user %d connected to legacy thread (%d) from %s", visitor.getUid(), MID, hXRealIP));
sockSubscr = new SocketSubscribed(session, hXRealIP, visitor, true);
sockSubscr.MID = MID;