aboutsummaryrefslogtreecommitdiff
path: root/juick-xmpp-bot/src/main/java/com/juick/components/XMPPBot.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-12-19 13:41:23 +0300
committerGravatar Vitaly Takmazov2016-12-19 13:41:23 +0300
commit274de5ede59ed4023826a9db09ec60788bc950e1 (patch)
tree107dbca37f559666eb065989aa92fd81e79fef24 /juick-xmpp-bot/src/main/java/com/juick/components/XMPPBot.java
parentacddd380e1868e28491eaf85f05e87d7a47a123f (diff)
all projects except juick-www are spring-managed now
Diffstat (limited to 'juick-xmpp-bot/src/main/java/com/juick/components/XMPPBot.java')
-rw-r--r--juick-xmpp-bot/src/main/java/com/juick/components/XMPPBot.java11
1 files changed, 5 insertions, 6 deletions
diff --git a/juick-xmpp-bot/src/main/java/com/juick/components/XMPPBot.java b/juick-xmpp-bot/src/main/java/com/juick/components/XMPPBot.java
index 15ba073e..55ae0b7d 100644
--- a/juick-xmpp-bot/src/main/java/com/juick/components/XMPPBot.java
+++ b/juick-xmpp-bot/src/main/java/com/juick/components/XMPPBot.java
@@ -2,16 +2,15 @@ package com.juick.components;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.juick.User;
-import com.juick.server.UserQueries;
import com.juick.server.helpers.UserInfo;
import com.juick.server.protocol.JuickProtocol;
import com.juick.server.protocol.ProtocolReply;
+import com.juick.service.UserService;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.env.Environment;
-import org.springframework.jdbc.core.JdbcTemplate;
import rocks.xmpp.addr.Jid;
import rocks.xmpp.core.XmppException;
import rocks.xmpp.core.stanza.model.Message;
@@ -32,7 +31,7 @@ import java.net.URL;
public class XMPPBot implements AutoCloseable {
private static final Logger logger = LoggerFactory.getLogger(XMPPBot.class);
@Inject
- JdbcTemplate jdbc;
+ UserService userService;
private ExternalComponent component;
@@ -51,7 +50,7 @@ public class XMPPBot implements AutoCloseable {
ownVCard.setUrl(new URL("http://juick.com/"));
ownVCard.setPhoto(new VCard.Image("image/png", IOUtils.toByteArray(getClass().getClassLoader().getResourceAsStream("vCard.png"))));
vCardManager.setVCard(ownVCard);
- JuickProtocol protocol = new JuickProtocol(jdbc, "http://juick.com/");
+ JuickProtocol protocol = new JuickProtocol("http://juick.com/");
component.addInboundMessageListener(e -> {
Message message = e.getMessage();
if (message.getType().equals(Message.Type.ERROR) || message.getType().equals(Message.Type.GROUPCHAT)) {
@@ -59,7 +58,7 @@ public class XMPPBot implements AutoCloseable {
}
String text = message.getBody().trim();
String command = text.toUpperCase();
- User user = UserQueries.getUserByJID(jdbc, message.getFrom().asBareJid().toString());
+ User user = userService.getUserByJID(message.getFrom().asBareJid().toString());
if (command.equals("VCARD")) {
try {
VCard vCard = vCardManager.getVCard(message.getFrom().asBareJid()).getResult();
@@ -67,7 +66,7 @@ public class XMPPBot implements AutoCloseable {
info.setFullName(vCard.getFormattedName());
info.setCountry(vCard.getAddresses().get(0).getCountry());
info.setUrl(vCard.getUrl().toString());
- UserQueries.updateUserInfo(jdbc, user, info);
+ userService.updateUserInfo(user, info);
component.sendMessage(new Message(message.getFrom(), Message.Type.CHAT, "vCard updated"));
} catch (XmppException vce) {
logger.warn("vcard exception", vce);