Commit 158e2839 authored by Guus der Kinderen's avatar Guus der Kinderen

Merge pull request #500 from surevine/OF-1034

OF-1034 Check for existing sessions properly
parents 3bd2679c 13a19a23
......@@ -38,6 +38,7 @@ import org.xmpp.packet.Message;
import org.xmpp.packet.Packet;
import org.xmpp.packet.PacketError;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
......@@ -250,9 +251,22 @@ public class MessageRouter extends BasicModule {
{
log.debug( "Message sent to unreachable address: " + packet.toXML() );
final Message msg = (Message) packet;
boolean storeOffline = true;
if ( msg.getType().equals( Message.Type.chat ) && serverName.equals( recipient.getDomain() ) && recipient.getResource() != null
&& routingTable.hasClientRoute( recipient.asBareJID() ) )
if ( msg.getType().equals( Message.Type.chat ) && serverName.equals( recipient.getDomain() ) && recipient.getResource() != null ) {
// Find an existing AVAILABLE session with non-negative priority.
for (JID address : routingTable.getRoutes(recipient.asBareJID(), packet.getFrom())) {
ClientSession session = routingTable.getClientRoute(address);
if (session != null && session.isInitialized()) {
if (session.getPresence().getPriority() >= 1) {
storeOffline = false;
}
}
}
}
if ( !storeOffline )
{
// If message was sent to an unavailable full JID of a user then retry using the bare JID.
routingTable.routePacket( recipient.asBareJID(), packet, false );
......
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