Commit 408fd4e5 authored by Derek DeMoro's avatar Derek DeMoro Committed by derek

Updating Live Assistant 2.0 Server to check for ChatBots


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@199 b35dd754-fafc-0310-a699-88a17e54d16e
parent 4903df13
...@@ -13,9 +13,11 @@ package org.jivesoftware.messenger.spi; ...@@ -13,9 +13,11 @@ package org.jivesoftware.messenger.spi;
import org.jivesoftware.messenger.container.BasicModule; import org.jivesoftware.messenger.container.BasicModule;
import org.jivesoftware.messenger.container.TrackInfo; import org.jivesoftware.messenger.container.TrackInfo;
import org.jivesoftware.messenger.container.ServiceLookupFactory;
import org.jivesoftware.util.LocaleUtils; import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log; import org.jivesoftware.util.Log;
import org.jivesoftware.messenger.*; import org.jivesoftware.messenger.*;
import org.jivesoftware.messenger.chatbot.ChatbotManager;
import org.jivesoftware.messenger.handler.IQHandler; import org.jivesoftware.messenger.handler.IQHandler;
import org.jivesoftware.messenger.auth.UnauthorizedException; import org.jivesoftware.messenger.auth.UnauthorizedException;
import java.util.HashMap; import java.util.HashMap;
...@@ -68,15 +70,22 @@ public class IQRouterImpl extends BasicModule implements IQRouter { ...@@ -68,15 +70,22 @@ public class IQRouterImpl extends BasicModule implements IQRouter {
} }
} }
private boolean isLocalServer(XMPPAddress recipientJID) {
private boolean isLocalServer(XMPPAddress recipientJID){ boolean isLocalServer = recipientJID == null || recipientJID.getHost() == null
// ridiculously long check for local server target || "".equals(recipientJID.getHost()) || recipientJID.getResource() == null
return recipientJID == null || "".equals(recipientJID.getResource());
|| recipientJID.getHost() == null
|| "".equals(recipientJID.getHost()) try {
|| ((recipientJID.getName() == null || "".equals(recipientJID.getName())) if(recipientJID != null){
&& (recipientJID.getResource() == null || "".equals(recipientJID.getResource()))); ChatbotManager chatBotManager = (ChatbotManager)ServiceLookupFactory.getLookup().lookup(ChatbotManager.class);
} isLocalServer = !chatBotManager.isChatbot(recipientJID);
}
}
catch (UnauthorizedException e) {
e.printStackTrace();
}
return isLocalServer;
}
private void handle(IQ packet) { private void handle(IQ packet) {
...@@ -98,10 +107,10 @@ public class IQRouterImpl extends BasicModule implements IQRouter { ...@@ -98,10 +107,10 @@ public class IQRouterImpl extends BasicModule implements IQRouter {
packet.setError(XMPPError.Code.NOT_IMPLEMENTED); packet.setError(XMPPError.Code.NOT_IMPLEMENTED);
} }
else { else {
// JID is of the form <node@domain> // JID is of the form <node@domain>
try { try {
// Let a "service" handle this packet otherwise return an error // Let a "service" handle this packet otherwise return an error
// Useful for MUC where node refers to a room and domain is the // Useful for MUC where node refers to a room and domain is the
// MUC service. // MUC service.
ChannelHandler route = routingTable.getRoute(recipientJID); ChannelHandler route = routingTable.getRoute(recipientJID);
if (route instanceof BasicModule) { if (route instanceof BasicModule) {
...@@ -130,7 +139,7 @@ public class IQRouterImpl extends BasicModule implements IQRouter { ...@@ -130,7 +139,7 @@ public class IQRouterImpl extends BasicModule implements IQRouter {
} }
else { else {
// JID is of the form <node@domain/resource> // JID is of the form <node@domain/resource>
ChannelHandler route = routingTable.getRoute(recipientJID); ChannelHandler route = routingTable.getRoute(recipientJID);
route.process(packet); route.process(packet);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment