aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/xmpp/s2s/ConnectionRouter.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-07-06 19:04:41 +0300
committerGravatar Vitaly Takmazov2016-07-06 19:04:41 +0300
commit02fd70cf59c30e3a9702eaf60d9e51f460efd8ca (patch)
treec76d3ec3465437c66c6a63d1afcc921d540edb23 /src/main/java/com/juick/xmpp/s2s/ConnectionRouter.java
parentd48e3b71c27d6782a63dda84aced58780b54f309 (diff)
static components are evil
Diffstat (limited to 'src/main/java/com/juick/xmpp/s2s/ConnectionRouter.java')
-rw-r--r--src/main/java/com/juick/xmpp/s2s/ConnectionRouter.java36
1 files changed, 19 insertions, 17 deletions
diff --git a/src/main/java/com/juick/xmpp/s2s/ConnectionRouter.java b/src/main/java/com/juick/xmpp/s2s/ConnectionRouter.java
index 0030834a..588cfe2c 100644
--- a/src/main/java/com/juick/xmpp/s2s/ConnectionRouter.java
+++ b/src/main/java/com/juick/xmpp/s2s/ConnectionRouter.java
@@ -27,8 +27,10 @@ public class ConnectionRouter implements Stream.StreamListener,
private String password;
Stream router;
Socket socket;
+ XMPPComponent xmpp;
- ConnectionRouter(String componentName, String password) {
+ ConnectionRouter(XMPPComponent s2s, String componentName, String password) {
+ this.xmpp = s2s;
this.componentName = componentName;
this.password = password;
reconnect();
@@ -56,11 +58,11 @@ public class ConnectionRouter implements Stream.StreamListener,
List<String> jids = new ArrayList<>();
if (jmsg.FriendsOnly) {
- jids = SubscriptionsQueries.getJIDSubscribedToUser(XMPPComponent.sql, jmsg.getUser().getUID(), jmsg.FriendsOnly);
+ jids = SubscriptionsQueries.getJIDSubscribedToUser(xmpp.sql, jmsg.getUser().getUID(), jmsg.FriendsOnly);
} else {
- List<User> users = SubscriptionsQueries.getSubscribedUsers(XMPPComponent.sql, jmsg.getUser().getUID(), jmsg.getMID());
+ List<User> users = SubscriptionsQueries.getSubscribedUsers(xmpp.sql, jmsg.getUser().getUID(), jmsg.getMID());
for (User user : users) {
- for (String jid : UserQueries.getJIDsbyUID(XMPPComponent.sql, user.getUID())) {
+ for (String jid : UserQueries.getJIDsbyUID(xmpp.sql, user.getUID())) {
jids.add(jid);
}
}
@@ -92,7 +94,7 @@ public class ConnectionRouter implements Stream.StreamListener,
for (String jid : jids) {
msg.to = new JID(jid);
- XMPPComponent.sendOut(msg);
+ xmpp.sendOut(msg);
}
}
@@ -101,9 +103,9 @@ public class ConnectionRouter implements Stream.StreamListener,
String replyQuote;
String replyTo;
- users = SubscriptionsQueries.getUsersSubscribedToComments(XMPPComponent.sql, jmsg.getMID(), jmsg.getUser().getUID());
- com.juick.Message replyMessage = jmsg.ReplyTo > 0 ? MessagesQueries.getReply(XMPPComponent.sql, jmsg.getMID(), jmsg.ReplyTo)
- : MessagesQueries.getMessage(XMPPComponent.sql, jmsg.getMID());
+ users = SubscriptionsQueries.getUsersSubscribedToComments(xmpp.sql, jmsg.getMID(), jmsg.getUser().getUID());
+ com.juick.Message replyMessage = jmsg.ReplyTo > 0 ? MessagesQueries.getReply(xmpp.sql, jmsg.getMID(), jmsg.ReplyTo)
+ : MessagesQueries.getMessage(xmpp.sql, jmsg.getMID());
replyTo = replyMessage.getUser().getUName();
replyQuote = getReplyQuote(replyMessage);
@@ -120,9 +122,9 @@ public class ConnectionRouter implements Stream.StreamListener,
msg.type = Message.Type.chat;
msg.addChild(jmsg);
for (User user : users) {
- for (String jid : UserQueries.getJIDsbyUID(XMPPComponent.sql, user.getUID())) {
+ for (String jid : UserQueries.getJIDsbyUID(xmpp.sql, user.getUID())) {
msg.to = new JID(jid);
- XMPPComponent.sendOut(msg);
+ xmpp.sendOut(msg);
}
}
}
@@ -140,8 +142,8 @@ public class ConnectionRouter implements Stream.StreamListener,
public void sendJuickRecommendation(JuickMessage recomm) {
List<User> users;
JuickMessage jmsg;
- jmsg = new JuickMessage(MessagesQueries.getMessage(XMPPComponent.sql, recomm.getMID()));
- users = SubscriptionsQueries.getUsersSubscribedToUserRecommendations(XMPPComponent.sql,
+ jmsg = new JuickMessage(MessagesQueries.getMessage(xmpp.sql, recomm.getMID()));
+ users = SubscriptionsQueries.getUsersSubscribedToUserRecommendations(xmpp.sql,
recomm.getUser().getUID(), recomm.getMID(), jmsg.getUser().getUID());
String txt = "Recommended by @" + recomm.getUser().getUName() + ":\n";
@@ -178,9 +180,9 @@ public class ConnectionRouter implements Stream.StreamListener,
}
for (User user : users) {
- for (String jid : UserQueries.getJIDsbyUID(XMPPComponent.sql, user.getUID())) {
+ for (String jid : UserQueries.getJIDsbyUID(xmpp.sql, user.getUID())) {
msg.to = new JID(jid);
- XMPPComponent.sendOut(msg);
+ xmpp.sendOut(msg);
}
}
}
@@ -190,7 +192,7 @@ public class ConnectionRouter implements Stream.StreamListener,
JID jid = iq.to;
if (!jid.Host.equals(componentName)) {
logger.info("STREAM ROUTER (IQ): " + iq.toString());
- XMPPComponent.sendOut(iq);
+ xmpp.sendOut(iq);
}
return false;
}
@@ -213,7 +215,7 @@ public class ConnectionRouter implements Stream.StreamListener,
}
}
} else {
- XMPPComponent.sendOut(xmsg);
+ xmpp.sendOut(xmsg);
}
}
@@ -222,7 +224,7 @@ public class ConnectionRouter implements Stream.StreamListener,
JID jid = presence.to;
if (!jid.Host.equals(componentName)) {
logger.info("STREAM ROUTER (PRESENCE): " + presence.toString());
- XMPPComponent.sendOut(presence);
+ xmpp.sendOut(presence);
}
}