Commit 490e5a7b 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@201 b35dd754-fafc-0310-a699-88a17e54d16e
parent 28ea6969
...@@ -11,19 +11,19 @@ ...@@ -11,19 +11,19 @@
package org.jivesoftware.messenger.spi; package org.jivesoftware.messenger.spi;
import org.jivesoftware.messenger.container.BasicModule;
import org.jivesoftware.messenger.container.TrackInfo;
import org.jivesoftware.messenger.container.ServiceLookupFactory;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.jivesoftware.messenger.*;
import org.jivesoftware.messenger.chatbot.ChatbotManager;
import org.jivesoftware.messenger.handler.IQHandler;
import org.jivesoftware.messenger.auth.UnauthorizedException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamException;
import org.jivesoftware.messenger.*;
import org.jivesoftware.messenger.auth.UnauthorizedException;
import org.jivesoftware.messenger.chatbot.ChatbotManager;
import org.jivesoftware.messenger.container.BasicModule;
import org.jivesoftware.messenger.container.ServiceLookupFactory;
import org.jivesoftware.messenger.container.TrackInfo;
import org.jivesoftware.messenger.handler.IQHandler;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
/** /**
* Generic presence routing base class. * Generic presence routing base class.
...@@ -44,12 +44,6 @@ public class IQRouterImpl extends BasicModule implements IQRouter { ...@@ -44,12 +44,6 @@ public class IQRouterImpl extends BasicModule implements IQRouter {
*/ */
public IQRouterImpl() { public IQRouterImpl() {
super("XMPP IQ Router"); super("XMPP IQ Router");
try {
chatBotManager = (ChatbotManager)ServiceLookupFactory.getLookup().lookup(ChatbotManager.class);
}
catch (UnauthorizedException e) {
Log.error(e);
}
} }
public void route(IQ packet) { public void route(IQ packet) {
...@@ -77,17 +71,26 @@ public class IQRouterImpl extends BasicModule implements IQRouter { ...@@ -77,17 +71,26 @@ public class IQRouterImpl extends BasicModule implements IQRouter {
} }
} }
private boolean isLocalServer(XMPPAddress recipientJID) { private boolean isLocalServer(XMPPAddress recipientJID) {
boolean isLocalServer = recipientJID == null || recipientJID.getHost() == null boolean isLocalServer = recipientJID == null || recipientJID.getHost() == null
|| "".equals(recipientJID.getHost()) || recipientJID.getResource() == null || "".equals(recipientJID.getHost()) || recipientJID.getResource() == null
|| "".equals(recipientJID.getResource()); || "".equals(recipientJID.getResource());
if(recipientJID != null){
isLocalServer = !chatBotManager.isChatbot(recipientJID); if (recipientJID != null && isLocalServer) {
} if (chatBotManager == null) {
return isLocalServer; try {
} chatBotManager = (ChatbotManager)ServiceLookupFactory.getLookup().lookup(ChatbotManager.class);
}
catch (UnauthorizedException e) {
Log.error(e);
}
}
isLocalServer = !chatBotManager.isChatbot(recipientJID);
}
return isLocalServer;
}
private void handle(IQ packet) { private void handle(IQ 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